This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Page tree
Skip to end of metadata
Go to start of metadata

Quick steps to generate a thrift interface for your language:

  • Download and install the thrift code generator
  • Navigate to the directory containing your .thrift files.
  • Run thrift with the options for your language of choice. e.g. thrift -php myproject.thrift
  • Your files will be generated in a sub directory called e.g. gen-php

Caveat: Service Method Parameter Naming

Make sure you don't name variables the same as their datatype - you WILL run in to trouble.

Consider this example BAD CODE:

typedef i32 somevariable

service Example {
    // Function that takes somevariable called somevariable  
    i32 regenerate(1:somevarable somevariable),
}

Though the Thrift compiler compiles this example successfully the generated code will NOT compile.

Also note that using terms like "new" as a function name will cause errors in the generated code.

Caveat: Service Method Name Overloading

Make sure you don't overload service methods.

service Example {
    // Two 'regenerate' functions with different arguments
    i32 regenerate(1:String foo),
    i32 regenerate(1:i16 bar),
}

Thrift will compile this, however the generated code will NOT compile.

  • No labels