jordan
jordan

Reputation: 751

finagle thrift generator for java

I have seen two tools to generate finagle compatible thrift.

  1. Is thrift-0.5.0-finagle too old? The latest is thrift 0.9. Can I still use it?

  2. Or should I use Scrooge? It generates a Java binding on Scala.

Upvotes: 2

Views: 1047

Answers (2)

diguage
diguage

Reputation: 397

You should use Scrooge. Scrooge is developed by Twitter. And Finagle is also developed by Twitter.

Tips:

The scrooge maven plugin should be configurated as follows

<plugin>
    <groupId>com.twitter</groupId>
    <artifactId>scrooge-maven-plugin</artifactId>
    <version>${scrooge.version}</version>
    <configuration>
        <thriftSourceRoot>${basedir}/src/main/thrift</thriftSourceRoot>
        <includes>
            <set>SyncWrite.thrift</set>
        </includes>
        <outputDirectory>${basedir}/src/main/gen/</outputDirectory>
        <thriftNamespaceMappings>
            <thriftNamespaceMapping>
                <from>com.ganji.cdc.xapian.thrift.cpp</from>
                <to>com.ganji.cdc.xapian.thrift.cpp</to>
            </thriftNamespaceMapping>
        </thriftNamespaceMappings>
        <language>experimental-java</language>
        <thriftOpts>
            <thriftOpt>--finagle</thriftOpt>
        </thriftOpts>
        <buildExtractedThrift>false</buildExtractedThrift>
    </configuration>
    <executions>
        <execution>
            <id>thrift-sources</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
        <execution>
            <id>thrift-test-sources</id>
            <phase>generate-test-sources</phase>
            <goals>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The language is experimental-java. If you configurated as Scrooge document, use java, the libthrift library must use 0.5.0.

There is the dependent library as follows

<finagle.version>6.25.0</finagle.version>
<scrooge.version>3.18.1</scrooge.version>

<!-- Finagle Start -->
<dependency>
    <groupId>org.apache.thrift</groupId>
    <artifactId>libthrift</artifactId>
    <version>0.9.0</version>
</dependency>
<dependency>
    <groupId>com.twitter</groupId>
    <artifactId>scrooge-core_2.10</artifactId>
    <version>${scrooge.version}</version>
</dependency>
<dependency>
    <groupId>com.twitter</groupId>
    <artifactId>scrooge-runtime_2.10</artifactId>
    <version>${scrooge.version}</version>
</dependency>
<dependency>
    <groupId>com.twitter</groupId>
    <artifactId>util-core_2.10</artifactId>
    <version>6.24.0</version>
</dependency>
<dependency>
    <groupId>com.twitter</groupId>
    <artifactId>finagle-core_2.10</artifactId>
    <version>${finagle.version}</version>
</dependency>
<dependency>
    <groupId>com.twitter</groupId>
    <artifactId>finagle-thrift_2.10</artifactId>
    <version>${finagle.version}</version>
</dependency>
<!-- Finagle End -->

That is all.

Upvotes: 0

user2233556
user2233556

Reputation: 31

If your project is Scala or Java, you should use Scrooge. thrift-0.5.0-finagle is being deprecated.

Upvotes: 3

Related Questions