![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
#include <router_stack.h>
Public Member Functions | |
| RouterStack (std::shared_ptr< ServiceProxies > services, const std::string &serviceName="routerStack", double secondsUntilLossAssumed=2.0) | |
| void | init () |
| virtual void | start (boost::function< void()> onStop=boost::function< void()>()) |
| virtual void | sleepUntilIdle () |
| virtual void | shutdown () |
| virtual size_t | numNonIdle () const |
| void | submitAuction (const std::shared_ptr< Auction > &auction, const Id &adSpotId, const Auction::Response &response) |
| void | notifyFinishedAuction (const Id &auctionId) |
| int | numAuctionsInProgress () |
| Json::Value | getStats () const |
| void | injectWin (const Id &auctionId, const Id &adSpotId, Amount winPrice, Date timestamp, const JsonHolder &winMeta, const UserIds &uids, const AccountKey &account, Date bidTimestamp) |
| void | injectLoss (const Id &auctionId, const Id &adSpotId, Date timestamp, const JsonHolder &lossMeta, const AccountKey &account, Date bidTimestamp) |
| void | injectCampaignEvent (const std::string &label, const Id &auctionId, const Id &spotId, Date timestamp, const JsonHolder &eventMeta, const UserIds &uids) |
| void | notifyFinishedSpot (const Id &auctionId, const Id &adSpotId) |
| void | initStatePersistence (const std::string &path) |
| void | addBudget (const AccountKey &account, CurrencyPool amount) |
| void | setBudget (const AccountKey &account, CurrencyPool amount) |
| void | topupTransfer (const AccountKey &account, CurrencyPool amount) |
Public Attributes | |
| Router | router |
| Redis::RedisTemporaryServer | redis |
| MasterBanker | masterBanker |
| SlaveBudgetController | budgetController |
| PostAuctionLoop | postAuctionLoop |
| AgentConfigurationService | config |
| MonitorEndpoint | monitor |
| bool | initialized |
The Router Stack is a Core Router, a Post Auction Loop and a Banker stuck together. This is mostly used for where we need an integrated component (simulations, etc); normally they would be run separately.
Definition at line 34 of file router_stack.h.
| void RTBKIT::RouterStack::addBudget | ( | const AccountKey & | account, |
| CurrencyPool | amount | ||
| ) |
Add budget to the given account. Returns the new accounting info for the account.
Definition at line 152 of file router_stack.cc.
| void RTBKIT::RouterStack::initStatePersistence | ( | const std::string & | path | ) | [inline] |
Place where the state persistence should be put.
Definition at line 145 of file router_stack.h.
| void RTBKIT::RouterStack::injectCampaignEvent | ( | const std::string & | label, |
| const Id & | auctionId, | ||
| const Id & | spotId, | ||
| Date | timestamp, | ||
| const JsonHolder & | eventMeta, | ||
| const UserIds & | uids | ||
| ) | [inline] |
Inject an IMPRESSION into the router, to be passed on to the campaign that bid on it.
If the spot ID is empty, then the click will be sent to all campaigns that had a win on the auction.
Definition at line 111 of file router_stack.h.
| void RTBKIT::RouterStack::injectLoss | ( | const Id & | auctionId, |
| const Id & | adSpotId, | ||
| Date | timestamp, | ||
| const JsonHolder & | lossMeta, | ||
| const AccountKey & | account, | ||
| Date | bidTimestamp | ||
| ) | [inline] |
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 94 of file router_stack.h.
| void RTBKIT::RouterStack::injectWin | ( | const Id & | auctionId, |
| const Id & | adSpotId, | ||
| Amount | winPrice, | ||
| Date | timestamp, | ||
| const JsonHolder & | winMeta, | ||
| const UserIds & | uids, | ||
| const AccountKey & | account, | ||
| Date | bidTimestamp | ||
| ) | [inline] |
Inject a WIN into the router. Thread safe and asynchronous.
Definition at line 76 of file router_stack.h.
| void RTBKIT::RouterStack::notifyFinishedSpot | ( | const Id & | auctionId, |
| const Id & | adSpotId | ||
| ) | [inline] |
Notify the router 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 139 of file router_stack.h.
| void RTBKIT::RouterStack::setBudget | ( | const AccountKey & | account, |
| CurrencyPool | amount | ||
| ) |
Set the budget for the given account. Returns the new accounting info for the account.
Definition at line 160 of file router_stack.cc.
| void RTBKIT::RouterStack::sleepUntilIdle | ( | ) | [virtual] |
Sleep until the router is idle (there are no more auctions and all connections are idle).
Definition at line 114 of file router_stack.cc.
| void RTBKIT::RouterStack::start | ( | boost::function< void()> | onStop = boost::function<void ()>() | ) | [virtual] |
Start the router running in a separate thread. The given lambda will be called when the thread is stopped.
Definition at line 102 of file router_stack.cc.
1.7.6.1