proxygen
NaiveRoutingDataHandler Class Reference
Inheritance diagram for NaiveRoutingDataHandler:
wangle::RoutingDataHandler< char > wangle::HandlerAdapter< R, W > wangle::Handler< R, R, W, W > wangle::HandlerBase< HandlerContext< R, W > >

Public Member Functions

 NaiveRoutingDataHandler (uint64_t connId, Callback *cob)
 
bool parseRoutingData (folly::IOBufQueue &bufQueue, RoutingData &routingData) override
 
- Public Member Functions inherited from wangle::RoutingDataHandler< char >
 RoutingDataHandler (uint64_t connId, Callback *cob)
 
 ~RoutingDataHandler () override
 
void read (Context *ctx, folly::IOBufQueue &q) override
 
void readEOF (Context *ctx) override
 
void readException (Context *ctx, folly::exception_wrapper ex) override
 
- Public Member Functions inherited from wangle::HandlerAdapter< R, W >
void read (Context *ctx, R msg) override
 
folly::Future< folly::Unitwrite (Context *ctx, W msg) override
 
- Public Member Functions inherited from wangle::Handler< R, R, W, W >
 ~Handler () override=default
 
virtual void read (Context *ctx, Rmsg)=0
 
virtual void readEOF (Context *ctx)
 
virtual void readException (Context *ctx, folly::exception_wrapper e)
 
virtual void transportActive (Context *ctx)
 
virtual void transportInactive (Context *ctx)
 
virtual folly::Future< folly::Unitwrite (Context *ctx, Wmsg)=0
 
virtual folly::Future< folly::UnitwriteException (Context *ctx, folly::exception_wrapper e)
 
virtual folly::Future< folly::Unitclose (Context *ctx)
 
- Public Member Functions inherited from wangle::HandlerBase< HandlerContext< R, W > >
virtual ~HandlerBase ()=default
 
virtual void attachPipeline (HandlerContext< R, W > *)
 
virtual void detachPipeline (HandlerContext< R, W > *)
 
HandlerContext< R, W > * getContext ()
 

Additional Inherited Members

- Public Types inherited from wangle::HandlerAdapter< R, W >
typedef Handler< R, R, W, W >::Context Context
 
- Public Types inherited from wangle::Handler< R, R, W, W >
typedef R rin
 
typedef R rout
 
typedef W win
 
typedef W wout
 
typedef HandlerContext< R, W > Context
 
- Static Public Attributes inherited from wangle::Handler< R, R, W, W >
static const HandlerDir dir
 

Detailed Description

A simple server that hashes connections to worker threads based on the first character typed in by the client.

Definition at line 35 of file accept_steering_server.cpp.

Constructor & Destructor Documentation

NaiveRoutingDataHandler::NaiveRoutingDataHandler ( uint64_t  connId,
Callback *  cob 
)
inline

Member Function Documentation

bool NaiveRoutingDataHandler::parseRoutingData ( folly::IOBufQueue bufQueue,
RoutingData &  routingData 
)
inlineoverridevirtual

Parse the routing data from bufQueue into routingData. This will be used to compute the hash for choosing the worker thread.

Bytes that need to be passed into the child pipeline (such as additional bytes left in bufQueue not used for parsing) should be moved into RoutingData::bufQueue.

Returns
bool - True on success, false if bufQueue doesn't have sufficient bytes for parsing

Implements wangle::RoutingDataHandler< char >.

Definition at line 40 of file accept_steering_server.cpp.

References folly::IOBufQueue::chainLength(), folly::IOBufQueue::move(), and folly::gen::move.

41  {
42  if (bufQueue.chainLength() == 0) {
43  return false;
44  }
45 
46  auto buf = bufQueue.move();
47  buf->coalesce();
48  // Use the first byte for hashing to a worker
49  routingData.routingData = buf->data()[0];
50  routingData.bufQueue.append(std::move(buf));
51  return true;
52  }
size_t chainLength() const
Definition: IOBufQueue.h:492
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > move()
Definition: IOBufQueue.h:459

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