All Projects → tanmaykm → Thrift.jl

tanmaykm / Thrift.jl

Licence: other
Thrift for Julia

Programming Languages

julia
2034 projects
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
Thrift
134 projects
shell
77523 projects

Projects that are alternatives of or similar to Thrift.jl

Spring Thrift Starter
Set of cool annotations that helps you building Thrift applications with Spring Boot
Stars: ✭ 151 (+504%)
Mutual labels:  thrift
Hibari
Hibari is a production-ready, distributed, ordered key-value, big data store. Hibari uses chain replication for strong consistency, high-availability, and durability. Hibari has excellent performance especially for read and large value operations.
Stars: ✭ 253 (+912%)
Mutual labels:  thrift
benchmark-thrift
An open source application designed to load test Thrift applications
Stars: ✭ 41 (+64%)
Mutual labels:  thrift
Elixir Thrift
A Pure Elixir Thrift Implementation
Stars: ✭ 182 (+628%)
Mutual labels:  thrift
Harpc
基于Thrift的跨语言、高可用、高性能、轻量级的RPC框架。
Stars: ✭ 229 (+816%)
Mutual labels:  thrift
thrift-parser
A Thrift Parser built in TypeScript that generates a TypeScript AST that retains the Thrift grammar
Stars: ✭ 84 (+236%)
Mutual labels:  thrift
Herringbone
Tools for working with parquet, impala, and hive
Stars: ✭ 134 (+436%)
Mutual labels:  thrift
thrift-typescript
Generate TypeScript from Thrift IDL files
Stars: ✭ 129 (+416%)
Mutual labels:  thrift
Osquery Go
Go bindings for osquery
Stars: ✭ 249 (+896%)
Mutual labels:  thrift
concrete-python
Python modules and scripts for working with Concrete, a data serialization format for NLP
Stars: ✭ 19 (-24%)
Mutual labels:  thrift
Thrift Tools
thrift-tools is a library and a set of tools to introspect Apache Thrift traffic.
Stars: ✭ 189 (+656%)
Mutual labels:  thrift
Go
decode/encode thrift message without IDL
Stars: ✭ 219 (+776%)
Mutual labels:  thrift
ThriftDemo PHP CPP
Demo for Thrift RPC framework. PHP client call CPP server.
Stars: ✭ 29 (+16%)
Mutual labels:  thrift
Finatra
Fast, testable, Scala services built on TwitterServer and Finagle
Stars: ✭ 2,126 (+8404%)
Mutual labels:  thrift
bloomery
Web UI for Impala
Stars: ✭ 15 (-40%)
Mutual labels:  thrift
Thrift Missing Guide
Thrift: The Missing Guide
Stars: ✭ 148 (+492%)
Mutual labels:  thrift
raster
A micro server framework, support coroutine, and parallel-computing, used for building flatbuffers/thrift/protobuf/http protocol service.
Stars: ✭ 19 (-24%)
Mutual labels:  thrift
LINE-Source
Line Application Source
Stars: ✭ 43 (+72%)
Mutual labels:  thrift
nomadgen
Configuration util in python syntax for Hashicorp's Nomad
Stars: ✭ 19 (-24%)
Mutual labels:  thrift
parquet-flinktacular
How to use Parquet in Flink
Stars: ✭ 29 (+16%)
Mutual labels:  thrift

Thrift.jl

Build Status

codecov

Apache Thrift is a lightweight, language-independent software stack with an associated code generation mechanism for RPC.

Thrift.jl is an implementation of Thrift for Julia, including a plugin for the Thrift IDL compiler.

Getting Started

Setting up Thrift for Julia

Install the Julia Thrift package: Pkg.add("Thrift").

Generating "Hello Julia"

A sample Hello Julia IDL and implementation is bundled along with the Thrift.jl package. It can be found under test/hello folder of the package.

It contains a Thrift IDL named hello.thrift, which contains a service SayHello with a hello method that returns a hello message for the supplied name in a randomly chosen language.

  1. Generate Julia sources from the IDL.

    Run Thrift.generate("hello.thrift") in the Julia REPL. This should result in a gen-jl folder with sources generated from the IDL placed in a folder hello (named after the IDL file name).

  2. Examine the generated files. Below is a brief explanation of the contents of the generated files.

    • hello_types.jl: contains Julia types for Thrift structs, exceptions and enums declared explicitly in the IDL along with other implicit types generated by the code generator.
    • hello_constants.jl: contains any constants declared in the IDL
    • SayHello.jl: code generated for the SayHello service.
    • hello.jl: contains a module named hello (named after the IDL file name), that includes the above mentioned generated files. It also includes a file named hello_impl.jl that is not generated, but must be created by the user.

Implementing "Hello Julia"

An implementation of the service methods are already provided as hello_impl.jl in the test/hello folder. It has an implementation of hello service method, that appends a randomly chosen greeting from the constant array GREETINGS to the supplied name.

  • Place the hello_impl.jl file in the gen-jl/hello folder.
  • The client and server implementations for this are already provided as clnt.jl and srvr.jl. Start the server with julia srvr.jl. Run the client with the command julia clnt.jl.

Setting and Getting Fields

Types used as Thrift structures are regular Julia types and the Julia syntax to set and get struct properties can be used on them. With fields that are set as optional, it is possible that some of them may not have been present in the instance that was read. The hasproperty method can be used to check before accessing such fields, otherwise an exception may be thrown on accessing a non-existent property.

  • getproperty(obj, prop::Symbol) : Same as obj.prop. Gets the value if it has been set. Throws an error otherwise.
  • setproperty!(obj, prop::Symbol, val) : Same as obj.prop = val. The value would be written on the wire when obj is serialized.
  • hasproperty(obj, prop::Symbol) : Checks whether property prop has been set in obj.
  • clear(obj) : Marks all fields of obj as unset.

The default constructor of Thrift structures make it easy to set large types with many properties during construction: T(; nvpairs...). For example:

julia> obj = MyThriftType(; prop1=1, prop2="hello");

Other Methods

  • copy!(to, from) : shallow copy of objects
  • isfilled(obj) : whether all mandatory fields are set
  • enumstr(enumname, enumvalue::Int32): returns a string with the enum field name matching the value
  • generate(specfile): generate Julia code for given Thrift IDL specification

On the Generated Code Structure

The generated code largely follows the scheme used in other languages, e.g. Python and C++. Each Thrift program (IDL file) is placed into a separate folder. The program (IDL file) name must be different from any of the service names defined in the program. Generated files may get clobbered if that is violated, because of filename clashes.

A Julia module is also generated bundle all sources together. Using the module is optional, though convenient in most cases. The example in test/calculator illustrates how to include multiple thrift generated services in a single Julia module, without using the autogenerated modules.

The generated service Processor now assumes that the implemented methods are present in the current module. Thus the generated code is not a complete module and requires the user to supply a service implementation to be complete. An alternative would be to make the generated code a complete module, and have the user supply an implementation module.

Service extensions are supported. The thrift processor on the server side passes on any methods it can not handle to the processor it extends from. Extensions of service clients are supported through Julia type extension.

The code generator can be tweaked in the future towards any preferred way of usage that may appear with further usage.

Implementation Status

Following is the status of protocols, transports and servers supported in the current implementation:

Protocol Implemented as  
Binary TBinaryProtocol
Compact TCompactProtocol
Transport Implemented as  
Socket TSocket and TServerSocket
Framed TFramedTransport
SASL TSASLClientTransport Only client side implementation as of now
Memory TMemoryTransport Can't be used with servers as of now
File TFileTransport Can't be used with servers as of now
Server Implemented as  
Blocking. Single Task. TSimpleServer Single process, blocking
Non Blocking Tasks. TTaskServer Single process. Asynchronous task spawned for each connection.
Non Blocking Multi Process. TProcessPoolServer Multi process, non blocking.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].