RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
examples/router_ex.cc
00001  /* router_ex.cc
00002    Eric Robert, 11 April 2013
00003    Copyright (c) 2012 Datacratic Inc.  All rights reserved.
00004 
00005    Program to run the router.
00006 */
00007 
00008 #include "rtbkit/core/router/router_runner.h"
00009 #include "rtbkit/plugins/exchange/http_exchange_connector.h"
00010 #include "jml/arch/timers.h"
00011 #include "jml/utils/json_parsing.h"
00012 #include "mock_exchange_connector.h"
00013 
00014 using namespace std;
00015 using namespace Datacratic;
00016 using namespace RTBKIT;
00017 
00018 namespace {
00019     struct Init {
00020         static ExchangeConnector * createMockExchange(ServiceBase * owner, std::string const & name) {
00021             return new MockExchangeConnector(*owner, name);
00022         }
00023 
00024         Init() {
00025             ExchangeConnector::registerFactory("mock", createMockExchange);
00026         }
00027     } init;
00028 }
00029 
00030 struct MockRouterRunner: public RouterRunner {
00031 
00032     MockRouterRunner()
00033     {
00034         logUris                   = {};
00035         exchangeConfigurationFile = "examples/mock-config.json";
00036         lossSeconds               = 15;
00037     }
00038 };
00039 
00040 int main(int argc, char ** argv)
00041 {
00042     MockRouterRunner runner;
00043 
00044     runner.doOptions(argc, argv);
00045 
00046     runner.init();
00047     runner.start();
00048 
00049     runner.router->forAllExchanges([](std::shared_ptr<ExchangeConnector> const & item) {
00050         item->enableUntil(Date::positiveInfinity());
00051     });
00052 
00053     for (;;) {
00054         ML::sleep(10.0);
00055     }
00056 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator