New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decision #30
Decision #30
Conversation
…r to pass extended requests
examples/bidder/http_bidder_test.cpp
Outdated
@@ -42,13 +46,15 @@ auto random_pick(int max) { | |||
return dis(gen); | |||
} | |||
|
|||
|
|||
class http_bidder_decisions_manager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used , can be removed.
int main(int argc, char *argv[]) { | ||
using namespace std::placeholders; | ||
using namespace vanilla::exchange; | ||
using namespace std::chrono_literals; | ||
using restful_dispatcher_t = http::crud::crud_dispatcher<http::server::request, http::server::reply> ; | ||
using BidRequest = openrtb::BidRequest<std::string>; | ||
//using BidRequest = openrtb::BidRequest<std::string>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we stick to original idea DSL::serialized and DSL::deserialized ?
See the use case in exchange_handler_test.cpp
using DSLT = DSL::GenericDSL<std::string> ;
using BidRequest = DSLT::deserialized_type;
using BidResponse = DSLT::serialized_type;
This will eliminate a need to use exchange_hander::types_blah_blah_blah
examples/bidder/http_bidder_test.cpp
Outdated
}; | ||
const decision_exchange_type::decision_tree_type decision_tree = {{ | ||
{static_cast<int> (decision_codes_type::USER_DATA), | ||
{request_user_data_f, static_cast<int> (decision_codes_type::AUCTION_ASYNC), static_cast<int> (decision_codes_type::NO_BID),}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra comma after NO_BID)** ,**
auto auction_async_f = [&bid_handler](http::server::reply &reply, BidRequest & bid_request) -> bool { | ||
return bid_handler.handle_auction_async(reply, bid_request); | ||
}; | ||
const decision_exchange_type::decision_tree_type decision_tree = {{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this format for readability ?
const decision_exchange_type::decision_tree_type decision_tree = {{
{ static_cast<int> (decision_codes_type::USER_DATA),
{request_user_data_f, static_cast<int> (decision_codes_type::AUCTION_ASYNC), static_cast<int> (decision_codes_type::NO_BID)}
},
{ static_cast<int> (decision_codes_type::NO_BID),
{no_bid_f, decision_exchange_type::decision_action::EXIT, decision_exchange_type::decision_action::EXIT}
},
{ static_cast<int> (decision_codes_type::AUCTION_ASYNC),
{auction_async_f, decision_exchange_type::decision_action::EXIT, decision_exchange_type::decision_action::EXIT}
}
}};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that It's not easy from this to define from the first look what are the output routes.
I'll try little bit different format.
I want to give decision tree user ability to define enum for decisions just in place it meant to be used, without additional namespaces.
But tree record with enum class seems redundant, too long etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sample code below is more readable because it's very compact, and yes I agree it's hard to see the output routes, so formatting definitely helps to improve readability even with enums.
decision_tree_manager<3> tm = decision_tree<3>
{{
{ 0 , { action_1, -1 , 1} }, //true->EXIT , false->index=1
{ 1 , { action_2, -1 , 2} }, //true->EXIT , false->index=2
{ 2 , { action_3, -1 , -1} } //EXIT
}} ;
examples/bidder/http_bidder_test.cpp
Outdated
} | ||
return response; | ||
}); | ||
thread_local vanilla::ResponseBuilder<BidderConfig> response_builder(caches); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename ResponseBuilder to Bidder ? Because it uses cache selector and filters and creates response. From reading this part of code it's hard to tell where the actual bidding occurs.
So this could be potential our bidder class?
thread_local vanilla::Bidder<BidderConfig> bidder(caches);
return bidder.process(request);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its good idea
examples/bidder/http_bidder_test.cpp
Outdated
exchange_handler<DSL::GenericDSL<>> bid_handler(std::chrono::milliseconds(config.data().timeout)); | ||
|
||
|
||
using bid_handler_type = exchange_handler<DSL::GenericDSL<>, vanilla::VanillaRequest>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now what's going on now ... the exchange_handler was designed to handle request in the generic way relying on DSL::serialized_type , DSL::deserialized_type , if we move it to vanilla::VanillaRequest then we'll need to maintain conversions for all different DSL types inside of
core/bid_request.hpp .
It basically breaks our model ?
I also see that user matching relies on vanilla::VanillaRequest as it has user_info.
We need to think about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Year the problem in in vanilla::BidRequest and VanillaRequest.
They are not flexible
we have to think about openrtb::BidRequest -> vanilla::BidRequest , perhaps vanilla::BidRequest needs to be generic wrapper around any BidRequest type , and in this case we can pass it as
Something like this ?
|
I'm trying to make Bidder class, vanilla::BidRequest and others more flexible |
Made some changes to make Bidder, multibidder_communicator and other more flexible. In exchagne_handler if I dont want to extend handling to auction data then |
public: | ||
multibidder_communicator(uint16_t bidders_port, Duration response_timeout) : | ||
response_timeout(response_timeout) { | ||
communicator.outbound(bidders_port); | ||
} | ||
|
||
template<typename T> | ||
void process(const vanilla::VanillaRequest &vanilla_request, multibidder_collector<T> &collector) { | ||
template<typename Request> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use any collector here ?
template<typename Request, typename Collector>
void process(const Request &request, Collector &collector) {
I would also suggest removing depencies on very nested types
DSL::serialized_type::data_type , and even further maybe in future replace
DSL::deserialized_type -> DSL::request_type
DSL::serialized_type -> DSL::response_type
Because I sometimes forget which one is which :-)
good work Arseny, let's push and see if we need to adjust it ! |
finally we have decision_router based on decision_tree to build our pipeline !!!! |
No description provided.