proxygen
BroadcastProxy.cpp File Reference

Go to the source code of this file.

Classes

class  ByteToStringDecoder
 
class  StringToByteEncoder
 
class  ClientIPRoutingDataHandler
 
class  ClientIPRoutingDataHandlerFactory
 
class  SimpleServerPool
 
class  SimpleBroadcastPipelineFactory
 
class  SimpleObservingPipelineFactory
 

Typedefs

using SimpleObservingPipeline = ObservingPipeline< std::string >
 

Functions

 DEFINE_int32 (port, 8080,"Broadcast proxy port")
 
 DEFINE_int32 (upstream_port, 8081,"Upstream server port")
 
int main (int argc, char **argv)
 

Typedef Documentation

Function Documentation

DEFINE_int32 ( port  ,
8080  ,
"Broadcast proxy port"   
)
DEFINE_int32 ( upstream_port  ,
8081  ,
"Upstream server port"   
)
int main ( int  argc,
char **  argv 
)

Definition at line 212 of file BroadcastProxy.cpp.

References folly::init().

212  {
213  folly::Init init(&argc, &argv);
214 
215  auto serverPool = std::make_shared<SimpleServerPool>();
216 
217  // A unique BroadcastPipeline for each upstream server to fan-out the
218  // upstream messages to ObservingPipelines corresponding to each client.
219  auto broadcastPipelineFactory =
220  std::make_shared<SimpleBroadcastPipelineFactory>();
221 
222  // A unique ObservingPipeline is created for each client to subscribe
223  // to the broadcast.
224  auto observingPipelineFactory =
225  std::make_shared<SimpleObservingPipelineFactory>(
226  serverPool, broadcastPipelineFactory);
227 
228  // RoutingDataHandlerFactory for creating the RoutingDataHandler that sets
229  // client IP as the routing data.
230  auto routingHandlerFactory =
231  std::make_shared<ClientIPRoutingDataHandlerFactory>();
232 
234 
235  // AcceptRoutingPipelineFactory for creating accept pipelines hash the
236  // client connection to a worker thread based on client IP.
237  auto acceptPipelineFactory = std::make_shared<
239  &server, routingHandlerFactory, observingPipelineFactory);
240 
241  server.pipeline(acceptPipelineFactory);
242  server.bind(FLAGS_port);
243  server.waitForStop();
244 
245  return 0;
246 }
void init()
char ** argv