Book Image

Learning Apache Thrift

Book Image

Learning Apache Thrift

Overview of this book

With modern software systems being increasingly complex, providing a scalable communication architecture for applications in different languages is tedious. The Apache Thrift framework is the solution to this problem! It helps build efficient and easy-to-maintain services and offers a plethora of options matching your application type by supporting several popular programming languages, including C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml, and Delphi. This book will help you set aside the basics of service-oriented systems through your first Apache Thrift-powered app. Then, progressing to more complex examples, it will provide you with tips for running large-scale applications in production environments. You will learn how to assess when Apache Thrift is the best tool to be used. To start with, you will run a simple example application, learning the framework's structure along the way; you will quickly advance to more complex systems that will help you solve various real-life problems. Moreover, you will be able to add a communication layer to every application written in one of the popular programming languages, with support for various data types and error handling. Further, you will learn how pre-eminent companies use Apache Thrift in their popular applications. This book is a great starting point if you want to use one of the best tools available to develop cross-language applications in service-oriented architectures.
Table of Contents (15 chapters)
Learning Apache Thrift
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
5
Generating and Running Code in Different Languages
Index

Getting a general idea of the example application


Before we get into coding, we need to know what to expect and what we can do to fulfil our expectations.

It this case, our requirement is to have an application that will let us test various Apache Thrift capabilities and be easy to implement and test. We want to have the server in one language and clients in two other languages.

Let's name our service MyToolbox and expose three methods that will perform the following actions:

  • The first method, get_distance, will return the distance, in kilometers (rounded up to the nearest integer), between two points on Earth, given their coordinates (we will use decimal degrees, whose format is popular in modern mapping applications, GPS devices, and so on, which express coordinates as decimal values instead of degrees, minutes, and seconds, and is used in cartography and navigation).

  • The second method, find_occurences, will take a string and a regular expression and return a list of all the lines in the input...