-
Notifications
You must be signed in to change notification settings - Fork 8
Add OpenRTB 2.6 proto types #390
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
base: main
Are you sure you want to change the base?
Changes from all commits
0fea734
6406e26
62caccb
cccb24c
a0e2fd2
e3410de
9877007
de12183
31f28fa
d4b7d8e
9eb1879
a74160e
c184e61
f5c59b1
4508e8f
b3480cd
2e4c5f3
95579a1
b939bbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ use crate::auction::context::ContextValue; | |
| use crate::creative; | ||
| use crate::error::TrustedServerError; | ||
| use crate::geo::GeoInfo; | ||
| use crate::openrtb::{OpenRtbBid, OpenRtbResponse, ResponseExt, SeatBid}; | ||
| use crate::openrtb::{OpenRtbBid, OpenRtbResponse, ResponseExt, SeatBid, ToExt}; | ||
| use crate::settings::Settings; | ||
| use crate::synthetic::{generate_synthetic_id, get_or_generate_synthetic_id}; | ||
|
|
||
|
|
@@ -205,7 +205,7 @@ pub fn convert_to_openrtb_response( | |
| auction_request: &AuctionRequest, | ||
| ) -> Result<Response, Report<TrustedServerError>> { | ||
| // Build OpenRTB-style seatbid array | ||
| let mut seatbids = Vec::new(); | ||
| let mut seatbids = Vec::with_capacity(result.winning_bids.len()); | ||
|
|
||
| for (slot_id, bid) in &result.winning_bids { | ||
| let price = bid.price.ok_or_else(|| { | ||
|
|
@@ -217,6 +217,34 @@ pub fn convert_to_openrtb_response( | |
| }) | ||
| })?; | ||
|
|
||
| let width = match i32::try_from(bid.width) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔧 Duplicated This inline Suggestion: Move |
||
| Ok(converted) => Some(converted), | ||
| Err(_) => { | ||
| log::warn!( | ||
| "Auction response: omitting bid width for auction {} slot {} bidder {} because width {} exceeds i32::MAX", | ||
| auction_request.id, | ||
| slot_id, | ||
| bid.bidder, | ||
| bid.width | ||
| ); | ||
| None | ||
| } | ||
| }; | ||
|
|
||
| let height = match i32::try_from(bid.height) { | ||
| Ok(converted) => Some(converted), | ||
| Err(_) => { | ||
| log::warn!( | ||
| "Auction response: omitting bid height for auction {} slot {} bidder {} because height {} exceeds i32::MAX", | ||
| auction_request.id, | ||
| slot_id, | ||
| bid.bidder, | ||
| bid.height | ||
| ); | ||
| None | ||
| } | ||
| }; | ||
|
|
||
| // Process creative HTML if present - rewrite URLs and return inline | ||
| let creative_html = if let Some(ref raw_creative) = bid.creative { | ||
| // Rewrite creative HTML with proxy URLs for first-party delivery | ||
|
|
@@ -241,19 +269,21 @@ pub fn convert_to_openrtb_response( | |
| }; | ||
|
|
||
| let openrtb_bid = OpenRtbBid { | ||
| id: format!("{}-{}", bid.bidder, slot_id), | ||
| impid: slot_id.to_string(), | ||
| price, | ||
| id: Some(format!("{}-{}", bid.bidder, slot_id)), | ||
| impid: Some(slot_id.to_string()), | ||
| price: Some(price), | ||
| adm: Some(creative_html), | ||
| crid: Some(format!("{}-creative", bid.bidder)), | ||
| w: Some(bid.width), | ||
| h: Some(bid.height), | ||
| adomain: Some(bid.adomain.clone().unwrap_or_default()), | ||
| w: width, | ||
| h: height, | ||
| adomain: bid.adomain.clone().unwrap_or_default(), | ||
| ..Default::default() | ||
| }; | ||
|
|
||
| seatbids.push(SeatBid { | ||
| seat: Some(bid.bidder.clone()), | ||
| bid: vec![openrtb_bid], | ||
| ..Default::default() | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -272,17 +302,19 @@ pub fn convert_to_openrtb_response( | |
| .collect(); | ||
|
|
||
| let response_body = OpenRtbResponse { | ||
| id: auction_request.id.to_string(), | ||
| id: Some(auction_request.id.to_string()), | ||
| seatbid: seatbids, | ||
| ext: Some(ResponseExt { | ||
| ext: ResponseExt { | ||
| orchestrator: OrchestratorExt { | ||
| strategy: strategy_name.to_string(), | ||
| providers: result.provider_responses.len(), | ||
| total_bids: result.total_bids(), | ||
| time_ms: result.total_time_ms, | ||
| provider_details, | ||
| }, | ||
| }), | ||
| } | ||
| .to_ext(), | ||
| ..Default::default() | ||
| }; | ||
|
|
||
| let body_bytes = | ||
|
|
||
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.
📌 CI
protocinstall is uncached and somewhat fragileapt-get install -y protobuf-compilerruns withoutapt-get updateand uncached on every build. This usually works but can intermittently fail on runner image changes. Since the proto file changes rarely, consider:.rsfile and only regenerating via a script — eliminates this dependency entirely.