thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandre Patry <patry...@iro.umontreal.ca>
Subject Re: Example on using TFileTransport
Date Fri, 20 Mar 2009 15:45:04 GMT
Hi,

I've tried the TFileTransport class a while ago and had the problem 
described at 
http://publists.facebook.com/pipermail/thrift/2008-January/000357.html.

I thus wrote a transport class for c++ streams that I just added to the 
wiki (http://wiki.apache.org/thrift/C++StreamTransport).  I extracted 
the file from one of my project, so if you have trouble to compile it, 
do not hesitate to contact me or fix the wiki version.

I have no simple example at hand but all classes take a 
boost::shared_ptr<StreamT> in paramater and can be used as any other 
thrift transports.

If you have any question on this code, I will be glad to answer,

Alex

Martin Hejnfelt wrote:
> Hi,
>
> I'm working on a system that implements Thrift as the main protocol for
> connection between the clients and the server, all done in C++.
> The thrift service doesn't do much more that give an easy way of moving
> some structs to the server.
> Now my problem is that I have to find a way to store the information if
> the thrift server isn't reachable. I have some structs defined in the
> thrift file (which are then mapped to C++ classes) that gets filled with
> information and then methods to send these to the server. If the server
> is down I'd like to save these classes/thrift-structs  to a file
> (serialization I guess), and then load them back into the program, when
> the thrift server is back up. First I tried just to use regular istream
> and ostream methods of serialization, but as I found out, the success of
> this method apparently depends on the compiler (i.e. it doesn't work for
> me :). So read in the Thrift whitepaper about this TFileTransport
> "option", which seems to be able to do what I need (or maybe I
> misunderstood it). It looks like this "layer" is capable of writing
> thrift requests to a file, and then actually "replay" it (so I could
> replay the requests when the server is back up). However I can't find
> any good examples of using it. My question is then (finally :)):
> Can someone give me a short example of using this (if a short example is
> even possible)?
> I guess I "just" need to know how I could add and read events from it,
> in order to take an previous event, and "replay" to the client. (I see
> it has addEvent and readEvent methods, but how should I use these
> compared to/in conjunction with my existing client->DoWhatEverMethod()
> calls?
>
> Anyway, any help is appreciated :) Thanks in advance!
>
>
> Mvh. / Best Regards
>
> Martin Hejnfelt
>   


Mime
View raw message