1 Star 0 Fork 0

walter / finagle_scala_examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Finagle https://www.scala-lang.org/ Finagle是Twitter基于Netty开发的支持容错的、协议无关的RPC框架,该框架支撑了Twitter的核心服务。 服务发现

  • Eureka

  • Prana

  • Finagle

  • ZooKeeper

  • Consul
 分布式跟踪系统,比如naver的Pinpoint、Apache的HTrace,阿里的鹰眼Tracing、京东的Hydra、新浪的Watchman等。

https://gitee.com/walter80

http://twitter.github.io/finagle/guide/Quickstart.html $ git clone https://github.com/twitter/finagle.git $ cd finagle/doc/src/sphinx/code/quickstart $ ./sbt compile

$ ./sbt 'runMain Server' $ curl -D - localhost:8080 $ ./sbt 'runMain Client' $ ./sbt 'runMain Proxy' & $ curl --dump-header - --header "Host: twitter.com" localhost:8080

export http_proxy=socks5://127.0.0.1:1086 export https_proxy=$http_proxy export all_proxy=$http_proxy

sbt 'project client' 'run-main com.example.client.ClientStarter' sbt 'project server' 'run-main com.example.server.ServerStarter'

sbt "project finagle-example" 'run-main com.example.server.ServerStarter'

sbt "project finagle-example" 'run-main com.twitter.finagle.example.thrift.ThriftServer'

sbt container:start sbt package

$ cd finagle $ ./sbt "project finagle-http" console ...build output... scala>

brew install sphinx-doc curl -i -H "Content-Type: application/json" -d '{"pname": "p123"}' http://localhost:9001

finagle-core_2.12

brew update brew install scala

~  scala Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 13.0.2). Type in expressions for evaluation. Or try :help. To use with IntelliJ, set the Scala home to: /usr/local/opt/scala/idea

vi ~/.zshrc

echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

export SCALA_HOME=/usr/local/Cellar/scala/2.11.8 export PATH=$PATH:$SCALA_HOME/bin

/usr/local/Cellar/openjdk/13.0.2+8_2 brew uninstall java brew uninstall --ignore-dependencies java

/Users/wolingzong/finagle/build.sbt scalaVersion := "2.13.1"

sbt shell sbt:hello-scala> sbtVersion [info] 1.3.8

export SBT_OPTS="-Dsbt.override.build.repos=true"

sbt:hello-scala> show overrideBuildResolvers [info] true sbt:hello-scala> sbt:hello-scala> compile Mac缓存路径为 ~/Library/Caches/Coursier/v1 。 sbt:hello-scala> run [info] running main.scala.hello.Hello Hello, Scala https://zhuanlan.zhihu.com/p/82727108

scrooge 默认是会遍历 /src/main/thrift 目录下的 thrift文件

https://www.zmannotes.com/index.php/2015/10/27/popular-rpc-framework/

https://qiita.com/taketon_/items/21557a0aca525b949293 https://qiita.com/akishin/items/61630d628f4c8e141ef2 https://qiita.com/iwag@github/items/7d03292749d78c145112

Finagle HTTP and Thrift Clients \ Servers Example

This is example of how you can write Finagle HTTP / Thrift Servers / Clients.

git remote rm origin

已存在的文件夹或 Git 仓库 cd existing_folder git init git remote add origin git@gitee.com:walter80/finagle_scala_examples.git git add . git commit git push -u origin master

Try It!

To try it, you should run HTTP by following command:

$ sbt "run-main com.acme.Example.HttpServer"

Then you should run Thrift Server:

$ sbt "run-main com.acme.Example.ThriftServer"

And now we ready to do some test calls using HTTP Client:

$ sbt "run-main com.acme.Example.HttpClient"

At HTTP Client you should get following output:

))) Issuing two requests in parallel:
))) Received result for authorized request: hello world
))) Unauthorized request errored (as desired): com.acme.Example.HttpClient$InvalidRequest

Since HTTP Service also sending async request to Thrift Server using Thrift Client, in out put of HTTP Server you should see following output:

>> Received response: hi through Thrift

空文件

简介

finagle scala教程 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Scala
1
https://gitee.com/walter80/finagle_scala_examples.git
git@gitee.com:walter80/finagle_scala_examples.git
walter80
finagle_scala_examples
finagle_scala_examples
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891