Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
Added the timeout to the response (prebid#756)
Browse files Browse the repository at this point in the history
* Added the timeout to the response.

* Shorter property name... I think a bit better.
  • Loading branch information
dbemiller authored Dec 5, 2018
1 parent 9ecb8b5 commit e3f4e77
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 8 deletions.
9 changes: 4 additions & 5 deletions exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ import (
"time"

"github.com/golang/glog"
"golang.org/x/text/currency"

"github.com/mxmCherry/openrtb"

"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
"github.com/prebid/prebid-server/gdpr"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/prebid/prebid-server/pbsmetrics"
"github.com/prebid/prebid-server/prebid_cache_client"
"golang.org/x/text/currency"
)

// Exchange runs Auctions. Implementations must be threadsafe, and will be shared across many goroutines.
Expand Down Expand Up @@ -311,8 +309,9 @@ func (e *exchange) buildBidResponse(ctx context.Context, liveAdapters []openrtb_
// Extract all the data from the SeatBids and build the ExtBidResponse
func (e *exchange) makeExtBidResponse(adapterBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, req *openrtb.BidRequest, resolvedRequest json.RawMessage, errList []error) *openrtb_ext.ExtBidResponse {
bidResponseExt := &openrtb_ext.ExtBidResponse{
Errors: make(map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderError, len(adapterBids)),
ResponseTimeMillis: make(map[openrtb_ext.BidderName]int, len(adapterBids)),
Errors: make(map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderError, len(adapterBids)),
ResponseTimeMillis: make(map[openrtb_ext.BidderName]int, len(adapterBids)),
RequestTimeoutMillis: req.TMax,
}
if req.Test == 1 {
bidResponseExt.Debug = &openrtb_ext.ExtResponseDebug{
Expand Down
71 changes: 71 additions & 0 deletions exchange/exchangetest/tmax.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"incomingRequest": {
"ortbRequest": {
"id": "some-request-id",
"site": {
"page": "test.somepage.com"
},
"tmax": 500,
"imp": [
{
"id": "my-imp-id",
"video": {
"mimes": ["video/mp4"]
},
"ext": {
"appnexus": {
"placementId": 1
}
}
}
]
},
"usersyncs": {
"appnexus": "123"
}
},
"outgoingRequests": {
"appnexus": {
"expectRequest": {
"ortbRequest": {
"id": "some-request-id",
"site": {
"page": "test.somepage.com"
},
"user": {
"buyeruid": "123"
},
"tmax": 500,
"imp": [
{
"id": "my-imp-id",
"video": {
"mimes": ["video/mp4"]
},
"ext": {
"bidder": {
"placementId": 1
}
}
}
]
},
"bidAdjustment": 1.0
},
"mockResponse": {
"errors": ["appnexus-error"]
}
}
},
"response": {
"bids": {
"id": "some-request-id",
"ext": {
"tmaxrequest": 500,
"errors": {
"appnexus": ["appnexus-error"]
}
}
}
}
}
10 changes: 7 additions & 3 deletions openrtb_ext/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import (
// ExtBidResponse defines the contract for bidresponse.ext
type ExtBidResponse struct {
Debug *ExtResponseDebug `json:"debug,omitempty"`
// ExtResponseErrors defines the contract for bidresponse.ext.errors
// Errors defines the contract for bidresponse.ext.errors
Errors map[BidderName][]ExtBidderError `json:"errors,omitempty"`
// ExtResponseTimeMillis defines the contract for bidresponse.ext.responsetimemillis
// ResponseTimeMillis defines the contract for bidresponse.ext.responsetimemillis
ResponseTimeMillis map[BidderName]int `json:"responsetimemillis,omitempty"`
// ExtResponseUserSync defines the contract for bidresponse.ext.usersync
// RequestTimeoutMillis returns the timeout used in the auction.
// This is useful if the timeout is saved in the Stored Request on the server.
// Clients can run one auction, and then use this to set better connection timeouts on future auction requests.
RequestTimeoutMillis int64 `json:"tmaxrequest,omitempty"`
// ResponseUserSync defines the contract for bidresponse.ext.usersync
Usersync map[BidderName]*ExtResponseSyncData `json:"usersync,omitempty"`
}

Expand Down

0 comments on commit e3f4e77

Please sign in to comment.