RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends
RTBKIT::HttpExchangeConnector Struct Reference

#include <http_exchange_connector.h>

Inheritance diagram for RTBKIT::HttpExchangeConnector:
RTBKIT::ExchangeConnector Datacratic::HttpEndpoint Datacratic::ServiceBase Datacratic::PassiveEndpointT< SocketTransport > Datacratic::EventRecorder Datacratic::PassiveEndpoint Datacratic::EndpointBase Datacratic::Epoller Datacratic::AsyncEventSource DumpingExchangeConnector RTBKIT::GenericExchangeConnector RTBKIT::MockExchangeConnector RTBKIT::RubiconExchangeConnector TestRubiconExchangeConnector

List of all members.

Public Member Functions

 HttpExchangeConnector (const std::string &name, ServiceBase &parent)
 HttpExchangeConnector (const std::string &name, std::shared_ptr< ServiceProxies > proxies)
int numServingRequest () const
virtual Json::Value getServiceStatus () const
virtual void configure (const Json::Value &parameters)
void configureHttp (int numThreads, const PortRange &listenPort, const std::string &bindHost="*", bool performNameLookup=false, int backlog=DEF_BACKLOG, const std::string &auctionResource="/auctions", const std::string &auctionVerb="POST")
virtual void start ()
virtual void shutdown ()
virtual void enableUntil (Date date)
bool isEnabled (Date now=Date::now()) const
virtual void setAcceptBidRequestProbability (double prob)
virtual std::string exchangeName () const =0
virtual std::shared_ptr
< BidRequest
parseBidRequest (HttpAuctionHandler &connection, const HttpHeader &header, const std::string &payload)
virtual double getTimeAvailableMs (HttpAuctionHandler &connection, const HttpHeader &header, const std::string &payload)
virtual double getRoundTripTimeMs (HttpAuctionHandler &connection, const HttpHeader &header)
virtual HttpResponse getResponse (const HttpAuctionHandler &connection, const HttpHeader &requestHeader, const Auction &auction) const
virtual HttpResponse getDroppedAuctionResponse (const HttpAuctionHandler &connection, const Auction &auction, const std::string &reason) const
virtual HttpResponse getErrorResponse (const HttpAuctionHandler &connection, const Auction &auction, const std::string &errorMessage) const
virtual void handleUnknownRequest (HttpAuctionHandler &connection, const HttpHeader &header, const std::string &payload) const
virtual ExchangeCompatibility getCampaignCompatibility (const AgentConfig &config, bool includeReasons) const
virtual ExchangeCompatibility getCreativeCompatibility (const Creative &creative, bool includeReasons) const

Protected Types

typedef boost::function< void(std::shared_ptr
< Auction >, Date)> 
OnTimeout
typedef boost::function
< HttpAuctionHandler *()> 
HandlerFactory

Protected Member Functions

virtual std::shared_ptr
< ConnectionHandler
makeNewHandler ()
virtual std::shared_ptr
< HttpAuctionHandler
makeNewHandlerShared ()

Protected Attributes

double acceptAuctionProbability
Date enabledUntil
OnTimeout onTimeout
HandlerFactory handlerFactory
int numServingRequest_
 How many connections are serving a request.
int numThreads
 Configuration parameters.
PortRange listenPort
std::string bindHost
bool performNameLookup
int backlog
std::string auctionResource
std::string auctionVerb
std::unordered_map
< std::string, float > 
pingTimesByHostMs
 The ping time to known hosts in milliseconds.
float pingTimeUnknownHostsMs
 The ping time to assume for unknown hosts.

Friends

class HttpAuctionHandler

Detailed Description

Class that manages incoming auctions.

Definition at line 33 of file http_exchange_connector.h.


Member Typedef Documentation

typedef boost::function<HttpAuctionHandler * ()> RTBKIT::HttpExchangeConnector::HandlerFactory [protected]

Connection factory used to create HTTP connections. Unless your application is very specialized, the default will work fine.

Reimplemented from Datacratic::HttpEndpoint.

Definition at line 242 of file http_exchange_connector.h.

typedef boost::function<void (std::shared_ptr<Auction>, Date)> RTBKIT::HttpExchangeConnector::OnTimeout [protected]

Function to be called back when there is an auction timeout. It is rare that you would want to do anything with this as the router will automatically know that an auction has timed out.

Definition at line 236 of file http_exchange_connector.h.


Member Function Documentation

void RTBKIT::HttpExchangeConnector::configure ( const Json::Value parameters) [virtual]

Configure the exchange connector. The JSON provided is entirely interpreted by the exchange connector itself.

Implements RTBKIT::ExchangeConnector.

Reimplemented in RTBKIT::MockExchangeConnector.

Definition at line 88 of file http_exchange_connector.cc.

void RTBKIT::HttpExchangeConnector::configureHttp ( int  numThreads,
const PortRange listenPort,
const std::string &  bindHost = "*",
bool  performNameLookup = false,
int  backlog = DEF_BACKLOG,
const std::string &  auctionResource = "/auctions",
const std::string &  auctionVerb = "POST" 
)

Configure just the HTTP part of the server.

Definition at line 103 of file http_exchange_connector.cc.

virtual void RTBKIT::HttpExchangeConnector::enableUntil ( Date  date) [inline, virtual]

Set the time until which the exchange is enabled. Normally this will be pushed forward a few seconds periodically so that everything will shut down if there is nothing controlling the exchange connector.

Implements RTBKIT::ExchangeConnector.

Definition at line 82 of file http_exchange_connector.h.

virtual std::string RTBKIT::HttpExchangeConnector::exchangeName ( ) const [pure virtual]

Return the name of the exchange, as it would be written as an identifier.

Implements RTBKIT::ExchangeConnector.

Implemented in RTBKIT::GenericExchangeConnector, RTBKIT::RubiconExchangeConnector, RTBKIT::MockExchangeConnector, and DumpingExchangeConnector.

Given an agent configuration, return a structure that describes the compatibility of each campaign and creative with the exchange.

If includeReasons is true, then the reasons structure should be filled in with a list of reasons for which the exchange rejected the creative or campaign. If includeReasons is false, the reasons should be all empty to save memory allocations. Note that it doesn't make much sense to have the reasons non-empty for creatives or campaigns that are approved.

The default implementation assumes that all campaigns and creatives are compatible with the exchange.

Reimplemented from RTBKIT::ExchangeConnector.

Reimplemented in RTBKIT::RubiconExchangeConnector.

Definition at line 268 of file http_exchange_connector.cc.

Tell if a given creative is compatible with the given exchange. See getCampaignCompatibility().

Reimplemented from RTBKIT::ExchangeConnector.

Reimplemented in RTBKIT::RubiconExchangeConnector.

Definition at line 277 of file http_exchange_connector.cc.

HttpResponse RTBKIT::HttpExchangeConnector::getDroppedAuctionResponse ( const HttpAuctionHandler connection,
const Auction auction,
const std::string &  reason 
) const [virtual]

Return a stringified JSON of the response for when we drop an auction.

Reimplemented in RTBKIT::GenericExchangeConnector, DumpingExchangeConnector, and RTBKIT::RubiconExchangeConnector.

Definition at line 230 of file http_exchange_connector.cc.

HttpResponse RTBKIT::HttpExchangeConnector::getErrorResponse ( const HttpAuctionHandler connection,
const Auction auction,
const std::string &  errorMessage 
) const [virtual]

Return a stringified JSON of the response for our auction. Default implementation calls getResponse() and stringifies the result.

This version is provided as it may be more efficient in terms of memory allocations.

The first element returned is the HTTP body, the second is the content type.

Reimplemented in DumpingExchangeConnector, RTBKIT::GenericExchangeConnector, and RTBKIT::RubiconExchangeConnector.

Definition at line 240 of file http_exchange_connector.cc.

HttpResponse RTBKIT::HttpExchangeConnector::getResponse ( const HttpAuctionHandler connection,
const HttpHeader requestHeader,
const Auction auction 
) const [virtual]

Return the HTTP response for our auction. Default implementation calls getResponse() and stringifies the result.

This version is provided as it may be more efficient in terms of memory allocations.

The first element returned is the HTTP body, the second is the content type.

Reimplemented in RTBKIT::MockExchangeConnector, RTBKIT::GenericExchangeConnector, and RTBKIT::RubiconExchangeConnector.

Definition at line 221 of file http_exchange_connector.cc.

double RTBKIT::HttpExchangeConnector::getRoundTripTimeMs ( HttpAuctionHandler connection,
const HttpHeader header 
) [virtual]

Return an estimate of how long a round trip with the connected server takes, in milliseconds at the exchange's latency percentile, including all hops (load balancers, reverse proxies, etc).

The default implementation returns 5ms, which is only valid for when a service is in the same datacenter. Many exchanges implement as part of their protocol a way to measure the round trip time between a given exchange host and a given bidder.

Reimplemented in RTBKIT::MockExchangeConnector, and RTBKIT::GenericExchangeConnector.

Definition at line 208 of file http_exchange_connector.cc.

Function to be called by something that wants to know the current status of this service. Returns a JSON object that could be inspected by a human or consumed by a service.

Reimplemented from Datacratic::ServiceBase.

Definition at line 170 of file http_exchange_connector.cc.

double RTBKIT::HttpExchangeConnector::getTimeAvailableMs ( HttpAuctionHandler connection,
const HttpHeader header,
const std::string &  payload 
) [virtual]

Return the available time for the bid request in milliseconds. This method should not parse the bid request, as when shedding load we want to do as little work as possible.

Most exchanges include this information in the HTTP headers.

Reimplemented in RTBKIT::MockExchangeConnector, RTBKIT::GenericExchangeConnector, and RTBKIT::RubiconExchangeConnector.

Definition at line 199 of file http_exchange_connector.cc.

void RTBKIT::HttpExchangeConnector::handleUnknownRequest ( HttpAuctionHandler connection,
const HttpHeader header,
const std::string &  payload 
) const [virtual]

Handles a request to a resource other than the auctionResource that is specified in the configuration. This can be used by exchange connectors to handle things like ready requests.

This method should always write a response on the connection.

Default will return a 404.

Definition at line 250 of file http_exchange_connector.cc.

bool RTBKIT::HttpExchangeConnector::isEnabled ( Date  now = Date::now()) const [inline]

Are we currently authorized to bid?

Definition at line 88 of file http_exchange_connector.h.

How many connections are serving a request at the moment?

Definition at line 46 of file http_exchange_connector.h.

std::shared_ptr< BidRequest > RTBKIT::HttpExchangeConnector::parseBidRequest ( HttpAuctionHandler connection,
const HttpHeader header,
const std::string &  payload 
) [virtual]

Parse the given payload into a bid request.

Reimplemented in RTBKIT::MockExchangeConnector, RTBKIT::GenericExchangeConnector, and RTBKIT::RubiconExchangeConnector.

Definition at line 190 of file http_exchange_connector.cc.

virtual void RTBKIT::HttpExchangeConnector::setAcceptBidRequestProbability ( double  prob) [inline, virtual]

Set which percentage of bid requests will be accepted by the exchange connector.

Implements RTBKIT::ExchangeConnector.

Definition at line 96 of file http_exchange_connector.h.

Shutdown the exchange connector ready to be destroyed.

Reimplemented from RTBKIT::ExchangeConnector.

Reimplemented in RTBKIT::GenericExchangeConnector.

Definition at line 130 of file http_exchange_connector.cc.

Start the exchange connector running

Reimplemented from RTBKIT::ExchangeConnector.

Reimplemented in RTBKIT::MockExchangeConnector.

Definition at line 122 of file http_exchange_connector.cc.


Member Data Documentation

Probability that we will accept a given auction.

Definition at line 224 of file http_exchange_connector.h.

Time until which the exchange is enabled. Normally this will be pushed forward a few seconds periodically so that everything will shut down if there is nothing controlling the exchange connector.

Definition at line 230 of file http_exchange_connector.h.


The documentation for this struct was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator