![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
Public Member Functions | |
PostAuctionLoop (ServiceBase &parent, const std::string &serviceName) | |
PostAuctionLoop (std::shared_ptr< ServiceProxies > proxies, const std::string &serviceName) | |
std::shared_ptr< Banker > | getBanker () const |
void | setBanker (const std::shared_ptr< Banker > &newBanker) |
void | throwException (const std::string &key, const std::string &fmt,...) __attribute__((__noreturn__)) |
template<typename... Args> | |
void | logMessage (const std::string &channel, Args...args) |
template<typename... Args> | |
void | logPAError (const std::string &function, const std::string &exception, Args...args) |
void | bindTcp () |
void | init () |
void | start (std::function< void()> onStop=std::function< void()>()) |
void | shutdown () |
size_t | numAwaitingWinLoss () const |
size_t | numFinishedAuctionsTracked () const |
void | initStatePersistence (const std::string &path) |
virtual Json::Value | getServiceStatus () const |
void | injectSubmittedAuction (const Id &auctionId, const Id &adSpotId, std::shared_ptr< BidRequest > bidRequest, const std::string &bidRequestStr, const std::string &bidRequestStrFormat, const JsonHolder &augmentations, const Auction::Response &bidResponse, Date lossTimeout) |
void | injectWin (const Id &auctionId, const Id &adspot, Amount winPrice, Date timestamp, const JsonHolder &winMeta, const UserIds &ids, const AccountKey &account, Date bidTimestamp) |
void | injectLoss (const Id &auctionId, const Id &adspot, Date timestamp, const JsonHolder &lossMeta, const AccountKey &account, Date bidTimestamp) |
void | injectCampaignEvent (const std::string &label, const Id &auctionId, const Id &adSpotId, Date timestamp, const JsonHolder &eventMeta, const UserIds &ids) |
void | notifyFinishedSpot (const Id &auctionId, const Id &adSpotId) |
std::string | getProviderName () const |
Json::Value | getProviderIndicators () const |
Public Attributes | |
std::shared_ptr< Banker > | banker |
uint64_t | numWins |
uint64_t | numLosses |
uint64_t | numCampaignEvents |
ZmqNamedPublisher | logger |
MonitorProviderClient | monitorProviderClient |
Date | lastWinLoss |
Date | lastCampaignEvent |
Definition at line 161 of file post_auction_loop.h.
void RTBKIT::PostAuctionLoop::bindTcp | ( | ) |
Start listening on ports for connections from agents, routers and event sources
Definition at line 342 of file post_auction_loop.cc.
Json::Value RTBKIT::PostAuctionLoop::getServiceStatus | ( | ) | const [virtual] |
Return service status.
Reimplemented from Datacratic::ServiceBase.
Definition at line 371 of file post_auction_loop.cc.
void RTBKIT::PostAuctionLoop::initStatePersistence | ( | const std::string & | path | ) |
The post auction loop has state which needs to hang around for a long time. We don't want this state to be lost if the post auction loop crashes, so we allow for it to be optionally saved to disk.
This call will read any old state which is in the given directory, and also start recording state changes to that directory.
It uses leveldb under the hood.
Definition at line 544 of file post_auction_loop.cc.
void RTBKIT::PostAuctionLoop::injectCampaignEvent | ( | const std::string & | label, |
const Id & | auctionId, | ||
const Id & | adSpotId, | ||
Date | timestamp, | ||
const JsonHolder & | eventMeta, | ||
const UserIds & | ids | ||
) |
Inject a campaign event into the router, to be passed on to the agent that bid on it.
If the spot ID is empty, then the click will be sent to all agents that had a win on the auction.
Definition at line 452 of file post_auction_loop.cc.
void RTBKIT::PostAuctionLoop::injectLoss | ( | const Id & | auctionId, |
const Id & | adspot, | ||
Date | timestamp, | ||
const JsonHolder & | lossMeta, | ||
const AccountKey & | account, | ||
Date | bidTimestamp | ||
) |
Inject a LOSS into the router. Thread safe and asynchronous. Note that this method ONLY is useful for simulations; otherwise losses are implicit.
Definition at line 426 of file post_auction_loop.cc.
void RTBKIT::PostAuctionLoop::injectSubmittedAuction | ( | const Id & | auctionId, |
const Id & | adSpotId, | ||
std::shared_ptr< BidRequest > | bidRequest, | ||
const std::string & | bidRequestStr, | ||
const std::string & | bidRequestStrFormat, | ||
const JsonHolder & | augmentations, | ||
const Auction::Response & | bidResponse, | ||
Date | lossTimeout | ||
) |
Transfer the given auction to the post auction loop. This method assumes that the given auction was submitted with a non-empty bid, and adds it to the internal data structures so that any post-auction messages can be matched up with it.
Definition at line 1422 of file post_auction_loop.cc.
void RTBKIT::PostAuctionLoop::injectWin | ( | const Id & | auctionId, |
const Id & | adspot, | ||
Amount | winPrice, | ||
Date | timestamp, | ||
const JsonHolder & | winMeta, | ||
const UserIds & | ids, | ||
const AccountKey & | account, | ||
Date | bidTimestamp | ||
) |
Inject a WIN into the post auction loop. Thread safe and asynchronous.
Definition at line 401 of file post_auction_loop.cc.
void RTBKIT::PostAuctionLoop::logMessage | ( | const std::string & | channel, |
Args... | args | ||
) | [inline] |
Log a given message to the given channel.
Definition at line 212 of file post_auction_loop.h.
void RTBKIT::PostAuctionLoop::logPAError | ( | const std::string & | function, |
const std::string & | exception, | ||
Args... | args | ||
) | [inline] |
Log a router error.
Definition at line 221 of file post_auction_loop.h.
void RTBKIT::PostAuctionLoop::notifyFinishedSpot | ( | const Id & | auctionId, |
const Id & | adSpotId | ||
) |
Notify the loop that the given auction/spot will never receive another message and should be forgotten. This is mostly for the simulation.
This message is the preferred way for a simulation to notify the router that things are finished; normally auctions finish by themselves (once submitted) but the auction/spot combination stays alive much longer waiting for further messages. You should only call finishedAuction in rare cases when you want to cancel an auction before bidding has finished.
If the auction doesn't exist, the message will be silently ignored.
There is no penalty for not calling this, apart from potentially having to wait one hour before the simulation decides that it is finished.
Definition at line 1453 of file post_auction_loop.cc.
void RTBKIT::PostAuctionLoop::throwException | ( | const std::string & | key, |
const std::string & | fmt, | ||
... | |||
) |
Throw an exception and log the error in Graphite and in the router log file.
Definition at line 378 of file post_auction_loop.cc.