25 using namespace folly;
41 RoutingData& routingData)
override {
46 auto buf = bufQueue.
move();
49 routingData.routingData = buf->data()[0];
50 routingData.bufQueue.append(
std::move(buf));
60 return std::make_shared<NaiveRoutingDataHandler>(connId, cob);
67 : routingData_(routingData) {}
70 std::stringstream out;
71 out <<
"You were hashed to thread " << std::this_thread::get_id()
72 <<
" based on '" << routingData_ <<
"'" << std::endl;
85 std::shared_ptr<AsyncTransportWrapper> sock,
86 const char& routingData,
88 std::shared_ptr<TransportInfo> transportInfo)
override {
89 auto pipeline = DefaultPipeline::create();
94 pipeline->setTransportInfo(transportInfo);
96 LOG(
INFO) <<
"Created new server pipeline. Local address = " 97 << *(transportInfo->localAddr)
98 <<
", remote address = " << *(transportInfo->remoteAddr);
107 auto routingHandlerFactory =
108 std::make_shared<NaiveRoutingDataHandlerFactory>();
109 auto childPipelineFactory = std::make_shared<ServerPipelineFactory>();
114 &server, routingHandlerFactory, childPipelineFactory));
115 server.
bind(FLAGS_port);
116 server.waitForStop();
std::shared_ptr< RoutingDataHandler< char > > newHandler(uint64_t connId, RoutingDataHandler< char >::Callback *cob) override
DefaultPipeline::Ptr newPipeline(std::shared_ptr< AsyncTransportWrapper > sock, const char &routingData, RoutingDataHandler< char > *, std::shared_ptr< TransportInfo > transportInfo) override
size_t chainLength() const
void write(const T &in, folly::io::Appender &appender)
bool parseRoutingData(folly::IOBufQueue &bufQueue, RoutingData &routingData) override
NaiveRoutingDataHandler(uint64_t connId, Callback *cob)
void bind(folly::AsyncServerSocket::UniquePtr s)
constexpr detail::Map< Move > move
DEFINE_int32(port, 23,"test server port")
std::unique_ptr< folly::IOBuf > move()
—— Concurrent Priority Queue Implementation ——
void init(int *argc, char ***argv, bool removeFlags)
int main(int argc, char **argv)
ServerBootstrap * pipeline(std::shared_ptr< AcceptPipelineFactory > factory)
std::shared_ptr< Pipeline > Ptr
Handler< R, R, W, W >::Context Context
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
int close(NetworkSocket s)
ThreadPrintingHandler(const char &routingData)
void transportActive(Context *ctx) override