Chapter 8. Implementing services
This chapter covers
- Best practices for designing Apache Thrift RPC services
- Implementing and testing service handlers
- Taking advantage of service interface evolution
- Using service inheritance hierarchies
The prior part II chapters examined transports, protocols, Apache Thrift IDL, and IDL-based user-defined types. This brings us to the top-shelf feature of the Apache Thrift framework—RPC services.
As we saw in chapter 7, the Apache Thrift IDL compiler generates languagespecific types for UDTs declared in IDL source files. These generated types can read and write themselves using any of the Apache Thrift serialization protocols. As we’ll see in this chapter, UDT serialization is an integral part of Apache Thrift RPC (figure 8.1).
Apache Thrift RPC services allow developers to create backend functionality in their preferred language and then expose that functionality to clients in any of more than 20 supported languages with no more than a few lines of code. Service interfaces are declared in Apache Thrift IDL and then compiled by the IDL compiler, which generates RPC client and server stubs for each service. RPC stubs allow clients to call remote functions in other languages as if the functions were locally defined. The required serialization and remote procedure call wiring is provided by the Apache Thrift IDL compiler.