![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* adserver_connector.h -*- C++ -*- 00002 Jeremy Barnes, 18 December 2012 00003 Copyright (c) 2012 Datacratic. All rights reserved. 00004 00005 Base class to connect to an ad server. We also have an http ad server 00006 connector that builds on top of this. 00007 */ 00008 00009 #pragma once 00010 00011 #include "soa/service/service_base.h" 00012 #include "soa/service/zmq_endpoint.h" 00013 #include "soa/types/id.h" 00014 #include "rtbkit/common/currency.h" 00015 #include "rtbkit/common/json_holder.h" 00016 #include "rtbkit/common/bid_request.h" 00017 #include "rtbkit/common/account_key.h" 00018 00019 00020 namespace RTBKIT { 00021 00022 00023 /*****************************************************************************/ 00024 /* ADSERVER CONNECTOR */ 00025 /*****************************************************************************/ 00026 00027 struct AdServerConnector : public Datacratic::ServiceBase { 00028 AdServerConnector(const std::string & serviceName, 00029 const std::shared_ptr<Datacratic::ServiceProxies> & proxy); 00030 virtual ~AdServerConnector(); 00031 00032 void init(std::shared_ptr<ConfigurationService> config); 00033 virtual void shutdown(); 00034 00035 virtual void start(); 00036 00037 void recordUptime() const; 00038 00039 /*************************************************************************/ 00040 /* METHODS TO SEND MESSAGES ON */ 00041 /*************************************************************************/ 00042 00045 void publishWin(const Id & auctionId, 00046 const Id & adSpotId, 00047 Amount winPrice, 00048 Date timestamp, 00049 const JsonHolder & winMeta, 00050 const UserIds & ids, 00051 const AccountKey & account, 00052 Date bidTimestamp); 00053 00058 void publishLoss(const Id & auctionId, 00059 const Id & adSpotId, 00060 Date timestamp, 00061 const JsonHolder & lossMeta, 00062 const AccountKey & account, 00063 Date bidTimestamp); 00064 00071 void publishCampaignEvent(const std::string & label, 00072 const Id & auctionId, 00073 const Id & adSpotId, 00074 Date timestamp, 00075 const JsonHolder & impressionMeta, 00076 const UserIds & ids); 00077 00078 Date startTime_; 00079 00080 private: 00081 // Connection to the post auction loops 00082 ZmqNamedProxy toPostAuctionService_; 00083 00084 // later... when we have multiple services 00085 //ZmqMultipleNamedClientBusProxy toPostAuctionServices; 00086 }; 00087 00088 } // namespace RTBKIT