RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* flume_endpoint.h -*- C++ -*- 00002 Jeremy Barnes, 15 November 2011 00003 Copyright (c) 2011 Datacratic. All rights reserved. 00004 00005 Endpoint that sets up a server that will listen for Flume events. 00006 */ 00007 00008 #ifndef __logger__flume_endpoint_h__ 00009 #define __logger__flume_endpoint_h__ 00010 00011 #include <boost/function.hpp> 00012 #include <boost/thread.hpp> 00013 #include <boost/shared_ptr.hpp> 00014 #include <string> 00015 #include <map> 00016 #include "soa/service/stats_events.h" 00017 00018 00019 namespace Datacratic { 00020 00021 00022 /*****************************************************************************/ 00023 /* FLUME RPC ENDPOINT */ 00024 /*****************************************************************************/ 00025 00028 struct FlumeRpcEndpoint { 00029 FlumeRpcEndpoint(); 00030 FlumeRpcEndpoint(int port); 00031 00032 ~FlumeRpcEndpoint(); 00033 00035 void init(int port); 00036 00037 void shutdown(); 00038 00040 boost::function<void (int64_t timestamp, 00041 int priority, 00042 const std::string & body, 00043 int64_t nanos, 00044 const std::string & host, 00045 const std::map<std::string, std::string> & meta)> 00046 onFlumeMessage; 00047 00049 boost::function<void ()> onClose; 00050 00052 void recordEvent(const std::string & event, 00053 EventType type = ET_COUNT, 00054 float value = 1.0) 00055 { 00056 if (onEvent) 00057 onEvent(event, type, value); 00058 } 00059 00060 std::function<void (std::string, EventType, float)> onEvent; 00061 00062 private: 00063 struct Handler; 00064 boost::shared_ptr<Handler> handler; 00065 }; 00066 00067 } // namespace Datacratic 00068 00069 #endif /* __logger__flume_endpoint_h__ */