Skip to content

Decision router

Vladimir Venediktov edited this page Jun 18, 2017 · 12 revisions

How to make your code less verbose and have configurable logical routes enabled

vanilla-rtb provides developers with a set of infrastructure classes capable to help you streamline development effort.

our core and common directories have some classes designed by our team to allow you configuring your logical routes when bidding on impressions.

and first implementation based on this class in our examples

used in our example for simple and most effective http_bidder capable to bid on every impression @ 50K QPS

Here is a snapshot of code with utilization of logical routes aka decisions based on outcome of actions

namespace bidder_decision_codes {
        enum {EXIT=-1, USER_DATA=0, NO_BID, AUCTION_ASYNC, SIZE};
}

implementation

const decision_router_type::decision_tree_type decision_tree = {{
        {bidder_decision_codes::USER_DATA, {request_user_data_f, bidder_decision_codes::AUCTION_ASYNC, bidder_decision_codes::NO_BID}},
        {bidder_decision_codes::NO_BID, {no_bid_f, bidder_decision_codes::EXIT, bidder_decision_codes::EXIT}},        
        {bidder_decision_codes::AUCTION_ASYNC, {auction_async_f, bidder_decision_codes::EXIT, bidder_decision_codes::EXIT}}
    }};
    decision_router_type decision_router(decision_tree);

What just happened is creation of decision routes based on outcome of function handler. How can you automate creation of those routes without writing code. Let's take Json as supported by vanilla text format and create a file describing those routes above.

{
decision_routes : [
   {index:0 , function:"request_user_data", true:2 , false:1},
   {index:1 , function:"no_bid", true:-1 , false:-1},
   {index:2 , function:"auction_async" , true:-1 , false:-1 }
]
}

This represents a very simple logic if user info available then continue bidding process and exit bidding process with bid response if user info is not available call no_bid function and exit bidding process with no bid response.

So now with a little or no programming effort you can map those into the code which maps 1-to-1 in this json doc.

The decision trees can grow and potentially become cyclical , so we are planning to provide you with compile time recursion checks to make sure your tree does not execute same node twice therefore becoming circular.