Skip to content

Decision router

Vladimir Venediktov edited this page Jun 4, 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 interesting classes designed by our team to allow you configuring your logical routes when bidding on impressions.

decision_tree

and first implementation based on this class in our examples

decision_router

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

http_bidder

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 you just set up are the decision routes based on outcome of function handler, provided you have configuration in JSON format , one can quickly imagine how those configuration can be loaded as decision routes in C++ code.

{
decision_routes : [
   {index:0 , function:"request_user_data", true:1 , 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.

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.