2

I have been looking on the net for an example of how to use thrift with facebook-swift in java but couldn't find anything.

Hasn't anyone got an example to share?

rojanu
  • 1,592
  • 5
  • 20
  • 34

2 Answers2

2

I put a brief example in this question:

Can generate .thrift files from existing java/scala interfaces and data types?

Both the Thrift website and the Swift github repo have separate examples, and my example from that question can be used to glue them together.

Basically, on the Thrift side you generate code as per the Thrift documentation.

Same thing on the Swift side.

However, on the Swift side instead of using the built in 'Nifty' server (you could if you want to, but your question sounds like you are trying to interop with the Thrift libraries) you can create a ThriftServiceProcessor as per my example and then convert it using NiftyProcessorAdapter to a normal TProcessor that can be passed into the standard Thrift Java library.

Hope that helps.

Community
  • 1
  • 1
BCG
  • 1,170
  • 8
  • 19
1

@BCG answer was good give me some starting points.

I have created an example of my findings and post it to GitHub.

if anybody needs it https://github.com/rojanu/thrift-swift-finagle-example

UPDATE I have updated the project at https://github.com/rojanu/thrift-swift-finagle-example Also, I have created forks of both facebook swift https://github.com/rojanu/swift and finagle https://github.com/rojanu/finagle. I have put local changes on to the forks and created pull requests for the both projects.

rojanu
  • 1,592
  • 5
  • 20
  • 34
  • Useful. I'm having issues resolving the finagle-swift_2.10 dependency. (I needed to change finagle.version from 6.22.0.1-SNAPSHOT to 6.22.0 to get swift-core, but it don't see a finagle-swift maven repo on the interwebs -- how should this be provided?) – user48956 Nov 25 '14 at 18:30
  • 1
    finagle-swift is from https://github.com/twitter/finagle.git. I had 6.22.0.1-SNAPSHOT as we made some local changes for internal use – rojanu Nov 25 '14 at 22:50
  • Thanks. "./sbt ‘project finagle-core' package -- works". But "./sbt ‘project finagle-swift' package" gives: "Not a valid project ID: finagle-swift". "./sbt package" also fails (missing ostrich dependency). Am I using sbt right for finagle? – user48956 Nov 26 '14 at 02:07
  • Sorry for not commenting earlier, finagle-swift entry in the build file is commented, just uncomment and it should build – rojanu Mar 01 '15 at 04:58