concept server event in category apache thrift

appears as: server events, server event
Programmer's Guide to Apache Thrift

This is an excerpt from Manning's book Programmer's Guide to Apache Thrift.

Many of the more robust Apache Thrift server platforms (C++, Java, C#, and others) support server events. Server events provide developers with a way to hook critical server state changes independent of the services running on the server so you can write one set of server event handlers and use it with all of your services. The server events fired by Apache Thrift are as follows:

In this section, we’ll look at server event processing. Server events allow you to monitor server activity independent of any service implementation. Server events are fired when the server accepts a connection, deletes a connection, or processes a request on a connection.

This can be useful in many scenarios. For example, imagine you’re interested in logging all the connections accepted by a server. Server events would be a good fit here because server events are independent of any service, making server event handlers useful with any server regardless of the service or services it supports.

10.5.3. Building a C++ thread pool server with server events

To gain practical experience with server event handlers we’ll build a new multithreaded server in C++ to handle message service requests. This server will use the C++ TThreadPoolServer class. The C++ TThreadPoolServer has a configurable thread pool size. However, should more connections than the server has threads arrive, the excess client connections will backlog. Backlogged connections get no service until an active connection disconnects, freeing a thread to service the next connection in the backlog (see figure 10.21).