Is the thrift-cpp client side thread safe?

I have three questions.

  • Is the client side saving lean flow?
  • Do they have some kind of connection pool for saving?
  • Any good practice to use thrift-cpp-client.

thanks!

+7
source share
2 answers

Thrift has doxygen docs, but they don't seem to be built. They are not very beautiful. To generate a copy, run (in the thrift source directory) doxygen -g Doxyfile , change RECURSIVE to YES, then run doxygen Doxyfile .

Answering your questions:

  • Which customer? There are a whole bunch of different lean transports. In general, there is no (AFAICT) of any global state, so you can create different clients in different threads. If you are trying to use the same transport in multiple threads, you probably need a manual lock if you have not read the code and confirmed that everything is in order.

  • I did not see him. AFAICT is only a bunch of transports that you can connect yourself. There is TSocketPool, but it is a load balancer that is not what I think you are looking for.

  • My advice: use only memory transport and create your own network. That Thrift is probably not what you want to do, and even so, their documentation and packaging are pretty bad. (Or use protocol buffers instead of thrift - they IMO are much better supported these days. I think this is despite being a thrifty contributor back when.)

+2
source

with savings of 0.12.

  1. Is the thrift-cpp client side thread-oriented? YES This is from an .h / .cpp file automatically generated by Thrift Compiler (0.12.0)

A "parallel" client is a thread-safe client that correctly handles non-standard responses. This is slower than a regular client, so it should be used only when you need to split the connection between multiple threads

Having defined ExampleService (example.thrift), you should have:

 class ExampleServiceConcurrentClient : virtual public ExampleServiceIf { } 
  1. Do they have some kind of pool of connections on the commission? NOT. You can create your own connection for each thread or use connectionConcurrentClient for all threads, this is your business.
  2. Any good practice to use thrift-cpp-client. MAY catch at least apache :: thrift :: TException on every service call
0
source

All Articles