Apache Thrift & eBrainPool Messaging

This is a Followup Post to eBrainPool Messaging System. What follows is my current understanding of how thrift works. I am still not competely sure that I have it right, and as I learn, I will append / change this post accordingly.

IDL file: we define the protocol in this form, thrift has it own datatypes etc, which it uses to generate appropriate code in the required language. C is of the language of choice for us. It seems new, not much discussion on C code, but there a great test code in there and the rest I am learning by reading the code from C++ and others. There is a separation of the logic into these parts. Server, Processor, Protocol, Transport

* our code is gtk, glib based, posting the functions here, as an example, will expand on this as the code moves into the main trunk. The Transport layer handles the low level reading and writing from a network. This seems to be and important part of the design, since it allows a decouple from the rest of the system. The separation here does have very intriguing possiblities and could quite possibly be why thrift is able to achieve what it does. key methods exposed (not complete, just a note which I found helped me understand, for devel mindsets) : open, close, read, write

Creating this is simple:

ThriftServerTransport *transport;
transport = THRIFT_SERVER_TRANSPORT(tsocket)

Now a level up from there, how does the data we have go into the right form, in order for the Transport layer to send it? The Protocol Layer handles this, seems to be capable of encoding and decoding beyond just simple XML, JSON, to binary, this particular aspect might have key elements for us to play with, as part of the overall design of eBrainPool (a topic for a later discussion, security, privacy related, perhaps stablity too )

A nice feature here, we do not need to know about the size of the string, or list etc..It is stream oriented. Cool, Very Cool. key methods exposed: writeMessageBegin, writeMessageEnd, WriteStructBegin, WriteStructEnd... etc.

ThriftProtocol *protocol;
                                                 'transport', transport, 0) );

Fine so far? Great, now next we need to able able to read and write our data in a set of formats we can choose from, and a lovely transport system, to transfer it across the network. What remains is a simple mechanism to connect the input to the output protocols. This is where The Processor fits in. All we really need to do from the developers perspective, seems to be to set the handler function, which we build. Finally, we put it all together in the Server. There are existing definitions for simple servers and threaded servers, which we can use and learn from.

*overly simplified, but in its simplest form, is something like this

ThriftSimpleServer *simpleserver = NULL;
simpleserver = g_object_new (THRIFT_TYPE_SIMPLE_SERVER, 'processor', processor,
                            'server_transport', THRIFT_SERVER_TRANSPORT (transport), NULL);

 -- as for the eBrainPool messaging itself, I currently have the IDL file defined and have glibc (c code) generated for the same. There is test server / client code stubs using the generated code, which I am working on.

This is a code in progess, and will be updated often. Instead of attaching it here, I will put it onto our GIT system and update this post with the link, etc.. here

All things considered, I think this suffices our needs and has enough capablities for growth.

Previous Post Next Post