-
Notifications
You must be signed in to change notification settings - Fork 84
Customizing BidRequest and BidResponse
Vanilla uses DSL mapper in its stack . The mapper works with boost::optional and it allows us to have missing fields in the message as long as openrtb::BidRequest uses boost::optional for that field. if you are planning to use different openRTB version other then we ship with vanilla-rtb we recommend doing it the followin way.
- Your project should be independent from vanilla-rtb , you don't want to modify our code in your fork as we periodically update our stack especially examples folder.
- Please use this model cmake project https://github.com/vanilla-rtb/rapid-bidder , it pulls vanilla-rtb as github submodule
- after you created directory outside of vanilla-rtb stack ( you can have same name directory DSL , placing under the root of your project , so in case of our model repository rapid-bidder it would be placed https://github.com/vanilla-rtb/rapid-bidder/ DSL
- if you add new fields to your custom::BidRequest, and make them optional even though they are optional the DSL extractor needs to know how to map them in case they are sent. So, if you see field in openrtb::BidRequest as optional , most likely we already provided DSL mapping code for them and you don't have to do anything , you can simply ignore sending this field in the message if this field not used in your message protocol. Basically if you see extra field don't rush to remove it may still work for you
- depending on if your goal very low latency , then should not keep a lot of optional unused fields as it effect performance of DSL mapper.
However if you decide to make very custom BidRequest not openRTB standard , this can be achieved by writing following code in your project's namespace.
//Put this file into $project-root/DSL
#include "your-project-root/DSL/openrtb_weibo.hpp"
template<typename T=std::string , unsigned int Size=128>
class WeiboDSL {
using deserialized_type = openrtb::weibo::BidRequest<T>;
using serialized_type = openrtb::weibo::BidResponse<T>;
using parse_error_type = jsonv::parse_error;
//....
//....
//....
};
//If you need to reuse some classes from vanilla-rtb
#include "rtb/core/openrtb.hpp"
namespace openrtb { namespace weibo {
template<typename T>
struct BidRequest {
~BidRequest() {}
T id; // 请求id 由wax 系统产生
std::vector<openrtb::Impression<T>> imp; //曝光对象,一次request可以包含多个imp
T dealid; // wax系统给参与prefered deal的dsp分配的deal id
std::vector<T> rule; // 此次流量命中的在DMP系统中注册的ruleid
boost::optional<openrtb::App> app; //应用对象
boost::optional<openrtb::Device> device; //设备对象
boost::optional<openrtb::User<T>> user; //用户对象
AuctionType at; // 竞拍方式 2 二阶竞价
};
}}
Sometimes during customization you may be able to refer to openrtb components like in above example openrtb::Impression openrtb::App However, if your product not openRTB compliant then all bets are off you will have to create your own BidRequest/BidResponse suite of classes and also write your own custom DSL mapper.