Thrift cross-service development framework and thrift development framework

Source: Internet
Author: User

Thrift cross-service development framework and thrift development framework

Thrift Overview

Thrift is a software framework used to develop scalable and cross-language services. It integrates powerful software stacks and code generation engines to build in C ++, Java, Python, PHP,
Ruby, Erlang, Perl, Haskell, C #, Cocoa, JavaScript, Node. js, Smalltalk, and OCaml are seamlessly integrated and efficient services.

Code generation tool command: "thrift-*. exe"-r-gen java./*. thrift generate gen-java directory

1. Basic Steps for server encoding:

* Implement service processing interface impl
* Create TProcessor // read and write
* Create a TServerTransport
* Create a TProtocol
* Create a TServer
* Start Server

2. Client encoding steps:

* Create a Transport
* Create a TProtocol
* Create a Client based on TTransport and TProtocol
* Call the corresponding Client Method

3. Data Transmission Protocol

* TBinaryProtocol: binary format.
* TCompactProtocol: compression format
* TJSONProtocol: JSON format
* TSimpleJSONProtocol: Provides JSON write-only protocol, and the generated files are easily parsed using the script language.

4. Server

* TSimpleServer single-thread mode test
* TNonblockingServer NIO selector loop listener
* THsHaServer uses a separate thread to process network I/O, and an independent worker thread pool to process messages
* TThreadedSelectorServer is non-blocking and multiple threads are used to process network I/O. It maintains two thread pools, one for network I/O processing and the other for request processing.
* The TThreadPoolServer uses the blocking socket method. The main thread is responsible for blocking listening to "listening for socket" to see if there are new sockets. The business processing is handled by a thread pool.

Project address: https://github.com/windwant/thrifttest

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.