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

Classes

struct  TimerWrapper
 

Public Member Functions

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

Private Attributes

folly::ThreadLocalPtr< ProxyStatsstats_
 
folly::ThreadLocal< TimerWrappertimer_
 

Detailed Description

Definition at line 37 of file ProxyServer.cpp.

Member Function Documentation

RequestHandler* ProxyHandlerFactory::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 53 of file ProxyServer.cpp.

References timer_.

53  {
54  return new ProxyHandler(stats_.get(), timer_->timer.get());
55  }
folly::ThreadLocal< TimerWrapper > timer_
Definition: ProxyServer.cpp:62
folly::ThreadLocalPtr< ProxyStats > stats_
Definition: ProxyServer.cpp:61
void ProxyHandlerFactory::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 39 of file ProxyServer.cpp.

References folly::TimeoutManager::NORMAL, and timer_.

39  {
40  stats_.reset(new ProxyStats);
41  timer_->timer = HHWheelTimer::newTimer(
42  evb,
43  std::chrono::milliseconds(HHWheelTimer::DEFAULT_TICK_INTERVAL),
45  std::chrono::seconds(FLAGS_server_timeout));
46  }
folly::ThreadLocal< TimerWrapper > timer_
Definition: ProxyServer.cpp:62
void reset(T *newPtr=nullptr)
Definition: ThreadLocal.h:176
folly::ThreadLocalPtr< ProxyStats > stats_
Definition: ProxyServer.cpp:61
void ProxyHandlerFactory::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 48 of file ProxyServer.cpp.

References timer_.

48  {
49  stats_.reset();
50  timer_->timer.reset();
51  }
folly::ThreadLocal< TimerWrapper > timer_
Definition: ProxyServer.cpp:62
void reset(T *newPtr=nullptr)
Definition: ThreadLocal.h:176
folly::ThreadLocalPtr< ProxyStats > stats_
Definition: ProxyServer.cpp:61

Member Data Documentation

folly::ThreadLocalPtr<ProxyStats> ProxyHandlerFactory::stats_
private

Definition at line 61 of file ProxyServer.cpp.

folly::ThreadLocal<TimerWrapper> ProxyHandlerFactory::timer_
private

Definition at line 62 of file ProxyServer.cpp.


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