Skip to content
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

Merged
merged 26 commits into from
Jan 17, 2018
Merged

OpenRTB Prebid Cache support #276

merged 26 commits into from
Jan 17, 2018

Conversation

dbemiller
Copy link
Contributor

@dbemiller dbemiller commented Jan 10, 2018

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.

@ghost ghost assigned dbemiller Jan 10, 2018
@ghost ghost added the in progress label Jan 10, 2018
@dbemiller dbemiller requested a review from hhhjort January 10, 2018 21:16
@dbemiller
Copy link
Contributor Author

@ndhimehta please send this to someone on rubicon as the second reviewer.

@ndhimehta
Copy link

@dbemiller Review scheduled for WO - 1/15.

@dbemiller dbemiller removed their assignment Jan 10, 2018
}
}

func (auction *auction) numImps() int {
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

}
}

func (auction *auction) forEachCachedBid(callback func(bid *openrtb.Bid, id string)) {
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@ghost ghost assigned dbemiller Jan 16, 2018
"strings"
)

// cacheBids stores the given Bids in prebid cache, and saves the generated UUIDs in the auction.
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

hhhjort
hhhjort previously approved these changes Jan 16, 2018
Copy link
Collaborator

@hhhjort hhhjort left a 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.

@dbemiller
Copy link
Contributor Author

One noteworthy change in the last few updates: @anwzhang pointed out that legacy mobile used hb_cache_id rather than hb_uuid. If we change this name, publishers have to update all their creatives in DFP.

So... I renamed the param to hb_cache_id, for legacy compatibility.

sandraleon
sandraleon previously approved these changes Jan 16, 2018
Copy link
Contributor

@sandraleon sandraleon left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// 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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Collaborator

@hhhjort hhhjort left a 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.

@dbemiller dbemiller merged commit 21da662 into master Jan 17, 2018
@dbemiller dbemiller deleted the cache-bids-support branch January 17, 2018 16:40
@ghost ghost removed the in progress label Jan 17, 2018
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 1, 2020
* 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.
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 2, 2020
* 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.
allar15 pushed a commit to allar15/prebid-server that referenced this pull request Nov 24, 2023
…-impression-release-tag

added release tag to imppression pixel
StarWindMoonCloud pushed a commit to ParticleMedia/prebid-server that referenced this pull request Jun 5, 2024
* rollout algo2 in-feed

* update

* update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenRTB support: Bid cache
4 participants