Finagle https://www.scala-lang.org/ Finagle是Twitter基于Netty开发的支持容错的、协议无关的RPC框架,该框架支撑了Twitter的核心服务。 服务发现
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
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
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。