-
Notifications
You must be signed in to change notification settings - Fork 765
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
OpenRTB Prebid Cache support #276
Conversation
…he new client can call it.
…enRTB serialization into the exchange.
…k behavior was actually untestable.
@ndhimehta please send this to someone on rubicon as the second reviewer. |
@dbemiller Review scheduled for WO - 1/15. |
exchange/auction.go
Outdated
} | ||
} | ||
|
||
func (auction *auction) numImps() int { |
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.
Is this function supposed to have a purpose outside of the one test case?
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.
It makes auction
nil-safe. The idea was to keep the "do we need to track winning bids?" logic in one place. If not, the exchange
can initialize the variable to a nil
. If so, the exchange can initialize a real auction
object.
Then the rest of the exchange
logic can call these functions as if it needed to track the winning bids without much performance impact.
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.
Wait I'm sorry.... no, you're right. It's not called anywhere real.
I'll delete it.
exchange/auction.go
Outdated
} | ||
} | ||
|
||
func (auction *auction) forEachCachedBid(callback func(bid *openrtb.Bid, id 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.
You don't seem to be using forEachCacheBid() at all?
Are you planning an interface definition that auction will need to implement, and if so shouldn't these be public functions?
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.
No plans... just sloppy of me. I'll delete it.
exchange/cache.go
Outdated
"strings" | ||
) | ||
|
||
// cacheBids stores the given Bids in prebid cache, and saves the generated UUIDs in the auction. |
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.
This caches all the best bids from each bidder from my reading. In any case you don't feed this function a list of bids to cache. Might want to clean up the comment, especially in light of the potential that we will eventually implement multiple different bid caching strategies, and this implements one specific strategy.
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.
agreed, thanks. I updated the comments to match.
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.
Looks good, and OpenRTB needs cache support.
… cache-bids-support
…blishers dont need to update their creatives in DFP.
One noteworthy change in the last few updates: @anwzhang pointed out that legacy mobile used So... I renamed the param to |
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.
just had a couple questions but looks good overall.
|
||
func (auction *auction) cacheId(bid *openrtb.Bid) (id string, exists bool) { | ||
id, exists = auction.cachedBids[bid] | ||
return |
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.
this returns values for id and exists?
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.
exchange/auction.go
Outdated
|
||
// forEachBestBid runs the callback function on every bid which is the highest one for each Bidder on each Imp. | ||
func (auction *auction) forEachBestBid(callback func(impID string, bidder openrtb_ext.BidderName, bid *openrtb.Bid, winner bool)) { | ||
if auction == nil { |
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.
is it necessary to check this? can auction be nil if it was able to call this function?
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.
no, you're right, it's not necessary. auction
is non-nil if targeting
is non-nil... and the only call to this function is after an if targeting == nil { return; }
block.
I removed it.
e := new(exchange) | ||
|
||
e.adapterMap = newAdapterMap(client, cfg) | ||
e.adapters = make([]openrtb_ext.BidderName, 0, len(e.adapterMap)) | ||
e.cache = cache | ||
e.cacheTime = time.Duration(cfg.CacheURL.ExpectedTimeMillis) * time.Millisecond |
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.
if this is not set in the config, cache time will be zero?
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.
correct. Do you think that makes sense as a default, or would it be better to have some time here?
Per the note here, I hope this doesn't become a long-term solution in any case.
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 fine to me, just wanted to make sure that was what we wanted.
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.
Changes since last review look good.
* Added the cache API contract classes, and renamed some existing ones for consistency. * Fixed some more bugs in the unmarshalling. * Made a Prebid Cache client which saved the entire bid as a JSON value. * Added a new test, and improved the cache implementation. * Ran gofmt. * Moved the GetBaseURL function onto the config.Cache struct, so that the new client can call it. * Separated the prebid cache client dependencies from OpenRTB. Moved OpenRTB serialization into the exchange. * Simplified cache implementation, because some of the graceful fallback behavior was actually untestable. * Added a cache client to the exchange. * basic default cache behavior. * Cached the best bid from each bidder in each imp. * Fixed tests and some bugs. * Added unit tests for the auction state. * Removed cache from the gitignore. * Fixed some bugs, and added some more unit tests. * Added error log for critical errors. * Some code logic simplifications. * Fixed another bug and added some more tests. * Made the reserved cache time configurable. * Ran gofmt. * Fixed issue prebid#199 in OpenRTB. * Removed a few unused methods. * Updated comment to be more accurate. * Renamed hb_uuid to hb_cache_id, for consistency with today so that publishers dont need to update their creatives in DFP. * Removed an unnecessary nil check.
* Added the cache API contract classes, and renamed some existing ones for consistency. * Fixed some more bugs in the unmarshalling. * Made a Prebid Cache client which saved the entire bid as a JSON value. * Added a new test, and improved the cache implementation. * Ran gofmt. * Moved the GetBaseURL function onto the config.Cache struct, so that the new client can call it. * Separated the prebid cache client dependencies from OpenRTB. Moved OpenRTB serialization into the exchange. * Simplified cache implementation, because some of the graceful fallback behavior was actually untestable. * Added a cache client to the exchange. * basic default cache behavior. * Cached the best bid from each bidder in each imp. * Fixed tests and some bugs. * Added unit tests for the auction state. * Removed cache from the gitignore. * Fixed some bugs, and added some more unit tests. * Added error log for critical errors. * Some code logic simplifications. * Fixed another bug and added some more tests. * Made the reserved cache time configurable. * Ran gofmt. * Fixed issue prebid#199 in OpenRTB. * Removed a few unused methods. * Updated comment to be more accurate. * Renamed hb_uuid to hb_cache_id, for consistency with today so that publishers dont need to update their creatives in DFP. * Removed an unnecessary nil check.
…-impression-release-tag added release tag to imppression pixel
* rollout algo2 in-feed * update * update
This fixes #216 and #199
The code is... pretty ugly, and a little embarrassing.
Normally I'd like to clean this up... but Prebid Mobile is being blocked by OpenRTB support in PBS, and this isn't the only thing left to do, so... I've gotta scope it somewhere.