Skip to content

Commit

Permalink
Prefer bidRequestOptions for bidderRequestStartTime
Browse files Browse the repository at this point in the history
- As of now, `bidderRequestStartTime` is part of `ExtraRequestInfo`. The ExtraRequestInfo is further passed as details to Adapter's MakeRequest() implementation.

- We don't want to pass bidderRequestStartTime details to `MakeRequest()`. So remove bidderRequestStartTime from ExtraRequestInfo and add it in bidRequestOptions.
  • Loading branch information
onkarvhanumante committed Jun 13, 2023
1 parent a73d9d6 commit ba2c1a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion adapters/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func (r *RequestData) SetBasicAuth(username string, password string) {

type ExtraRequestInfo struct {
PbsEntryPoint metrics.RequestType
BidderRequestStartTime time.Time
GlobalPrivacyControlHeader string
CurrencyConversions currency.Conversions
MakeBidsTimeInfo MakeBidsTimeInfo
Expand Down
13 changes: 7 additions & 6 deletions exchange/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ type AdaptedBidder interface {

// bidRequestOptions holds additional options for bid request execution to maintain clean code and reasonable number of parameters
type bidRequestOptions struct {
accountDebugAllowed bool
headerDebugAllowed bool
addCallSignHeader bool
bidAdjustments map[string]float64
accountDebugAllowed bool
headerDebugAllowed bool
addCallSignHeader bool
bidAdjustments map[string]float64
bidderRequestStartTime time.Time
}

const ImpIdReqBody = "Stored bid response for impression id: "
Expand Down Expand Up @@ -173,11 +174,11 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, bidderRequest Bidde
dataLen = len(reqData) + len(bidderRequest.BidderStoredResponses)
responseChannel = make(chan *httpCallInfo, dataLen)
if len(reqData) == 1 {
responseChannel <- bidder.doRequest(ctx, reqData[0], reqInfo.BidderRequestStartTime)
responseChannel <- bidder.doRequest(ctx, reqData[0], bidRequestOptions.bidderRequestStartTime)
} else {
for _, oneReqData := range reqData {
go func(data *adapters.RequestData) {
responseChannel <- bidder.doRequest(ctx, data, reqInfo.BidderRequestStartTime)
responseChannel <- bidder.doRequest(ctx, data, bidRequestOptions.bidderRequestStartTime)
}(oneReqData) // Method arg avoids a race condition on oneReqData
}
}
Expand Down
10 changes: 5 additions & 5 deletions exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,13 +697,13 @@ func (e *exchange) getAllBids(
reqInfo := adapters.NewExtraRequestInfo(conversions)
reqInfo.PbsEntryPoint = bidderRequest.BidderLabels.RType
reqInfo.GlobalPrivacyControlHeader = globalPrivacyControlHeader
reqInfo.BidderRequestStartTime = start

bidReqOptions := bidRequestOptions{
accountDebugAllowed: accountDebugAllowed,
headerDebugAllowed: headerDebugAllowed,
addCallSignHeader: isAdsCertEnabled(experiment, e.bidderInfo[string(bidderRequest.BidderName)]),
bidAdjustments: bidAdjustments,
accountDebugAllowed: accountDebugAllowed,
headerDebugAllowed: headerDebugAllowed,
addCallSignHeader: isAdsCertEnabled(experiment, e.bidderInfo[string(bidderRequest.BidderName)]),
bidAdjustments: bidAdjustments,
bidderRequestStartTime: start,
}
seatBids, err := e.adapterMap[bidderRequest.BidderCoreName].requestBid(ctx, bidderRequest, conversions, &reqInfo, e.adsCertSigner, bidReqOptions, alternateBidderCodes, hookExecutor, bidAdjustmentRules)

Expand Down

0 comments on commit ba2c1a3

Please sign in to comment.