proxygen
EchoHandlerFactory Class Reference
Inheritance diagram for EchoHandlerFactory:
proxygen::RequestHandlerFactory

Public Member Functions

void onServerStart (folly::EventBase *) noexceptoverride
 
void onServerStop () noexceptoverride
 
RequestHandleronRequest (RequestHandler *, HTTPMessage *) noexceptoverride
 
- Public Member Functions inherited from proxygen::RequestHandlerFactory
virtual ~RequestHandlerFactory ()
 

Private Attributes

folly::ThreadLocalPtr< EchoStatsstats_
 

Detailed Description

Definition at line 36 of file EchoServer.cpp.

Member Function Documentation

RequestHandler* EchoHandlerFactory::onRequest ( RequestHandler ,
HTTPMessage  
)
inlineoverridevirtualnoexcept

Invoked for each new request server handles. HTTPMessage is provided so that user can potentially choose among several implementation of handler based on URL or something. No need to save/copy this HTTPMessage. RequestHandler will be given the HTTPMessage in a separate callback.

Some request handlers don't handle the request themselves (think filters). They do take some actions based on request/response but otherwise they just hand-off request to some other RequestHandler. This upstream RequestHandler is given as first parameter. For the terminal RequestHandler this will by nullptr.

Implements proxygen::RequestHandlerFactory.

Definition at line 46 of file EchoServer.cpp.

46  {
47  return new EchoHandler(stats_.get());
48  }
folly::ThreadLocalPtr< EchoStats > stats_
Definition: EchoServer.cpp:51
void EchoHandlerFactory::onServerStart ( folly::EventBase evb)
inlineoverridevirtualnoexcept

Invoked in each thread server is going to handle requests before we start handling requests. Can be used to setup thread-local setup for each thread (stats and such).

Implements proxygen::RequestHandlerFactory.

Definition at line 38 of file EchoServer.cpp.

38  {
39  stats_.reset(new EchoStats);
40  }
void reset(T *newPtr=nullptr)
Definition: ThreadLocal.h:176
folly::ThreadLocalPtr< EchoStats > stats_
Definition: EchoServer.cpp:51
void EchoHandlerFactory::onServerStop ( )
inlineoverridevirtualnoexcept

Invoked in each handler thread after all the connections are drained from that thread. Can be used to tear down thread-local setup.

Implements proxygen::RequestHandlerFactory.

Definition at line 42 of file EchoServer.cpp.

42  {
43  stats_.reset();
44  }
void reset(T *newPtr=nullptr)
Definition: ThreadLocal.h:176
folly::ThreadLocalPtr< EchoStats > stats_
Definition: EchoServer.cpp:51

Member Data Documentation

folly::ThreadLocalPtr<EchoStats> EchoHandlerFactory::stats_
private

Definition at line 51 of file EchoServer.cpp.


The documentation for this class was generated from the following file: