-
Notifications
You must be signed in to change notification settings - Fork 770
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
OMS: Video support #4172
base: master
Are you sure you want to change the base?
OMS: Video support #4172
Conversation
oms: changed required parameters
Code coverage summaryNote:
omsRefer here for heat map coverage report
|
Related docs PR: prebid/prebid.github.io#5830 |
@@ -53,4 +56,5 @@ var invalidParams = []string{ | |||
`[]`, | |||
`{}`, | |||
`{"pid": "0"}`, | |||
`{"publisherId": 9999}`, |
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.
suggestion: add test covering wrong type as well, publisherId as 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.
Done.
adapters/oms/oms.go
Outdated
var publisherID string | ||
if len(request.Imp[0].Ext) > 0 { | ||
ext := pbsExt{} | ||
err = json.Unmarshal(request.Imp[0].Ext, &ext) |
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.
suggestion: please use jsonutil - so the choice of fastest json implementation can be central
err = json.Unmarshal(request.Imp[0].Ext, &ext) | |
err = jsonutil.Unmarshal(request.Imp[0].Ext, &ext) |
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.
Done.
adapters/oms/oms.go
Outdated
requestData := &adapters.RequestData{ | ||
Method: "POST", | ||
Uri: a.endpoint, | ||
Uri: a.endpoint + fmt.Sprintf("?publisherId=%v", publisherID), |
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.
suggestion: if you're already using sprintf, can you just include a.endpoint as an argument and %s where it goes?
Uri: a.endpoint + fmt.Sprintf("?publisherId=%v", publisherID), | |
Uri: fmt.Sprintf("%s?publisherId=%v", a.endpoint, publisherID), |
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.
Done.
@@ -72,12 +96,40 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R | |||
} | |||
for _, seatBid := range response.SeatBid { |
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.
suggestion/question: I'm curious about the type of SeatBid if it's an []SomeStruct then this should also use an index - otherwise, seatBid
will do a struct copy (shallow) for each loop iteration.
If the type supports it, consider something like this
for _, seatBid := range response.SeatBid { | |
for sbIndex := range response.SeatBid { | |
seatBid := &response.SeatBid[sbIndex] |
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.
These lines are unchanged.
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ | ||
Bid: &seatBid.Bid[i], | ||
BidType: openrtb_ext.BidTypeBanner, | ||
Bid: &seatBid.Bid[i], |
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.
observation/curiosity: hmm… so this is a pointer to the copy - see previous comment, is that intended? If you move to seatBid to a pointer, it'll point to that same instance's bid - that's efficient - any worries about contention here? you're not making changes here, I think it's ok
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.
Yes, these lines are unchanged.
}) | ||
} | ||
} | ||
|
||
return bidResponse, nil | ||
} | ||
|
||
func getBidType(markupType openrtb2.MarkupType) openrtb_ext.BidType { |
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.
observation: hmm… this seems like it could be general… is there some central place that can do this mapping?
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.
What you mean by central place
?
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.
After checking other adapters I made a conclusion that it depends on how any of them want to process bid types (some of them return error if mapping isn't succeeded, some of them return default value). In our case we want to support backward compatibility that's why banner type is returned as default value.
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.
@scr-oath are you asking if there is a helper function offered that can be used by any adapter? There isn't. We might be able to offer that at some point but we should keep in mind that not all adapters support the same media types and the default case will vary. Also some adapters will fall back to deriving the media type from the request imp if mtype
is not in the response.
…anged uri builder
Code coverage summaryNote:
omsRefer here for heat map coverage report
|
adapters/oms/oms.go
Outdated
requestData := &adapters.RequestData{ | ||
Method: "POST", | ||
Uri: a.endpoint, | ||
Uri: fmt.Sprintf("%s?publisherId=%v", a.endpoint, publisherID), |
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.
question: why do you need Itoa? Could you just use %d
to format the number into the query param?
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.
Done
Code coverage summaryNote:
omsRefer here for heat map coverage report
|
@@ -42,6 +42,9 @@ func TestInvalidParams(t *testing.T) { | |||
var validParams = []string{ | |||
`{"pid": "12345"}`, | |||
`{"pid": "123456"}`, | |||
`{"publisherId": 12345}`, | |||
`{"publisherId": 123456}`, | |||
`{"publisherId": 12345,"pid": "12345"}`, |
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.
Please add a valid boundary test for publisherId
:
{"publisherId": 10000}
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.
Done
}) | ||
} | ||
} | ||
|
||
return bidResponse, nil | ||
} | ||
|
||
func getBidType(markupType openrtb2.MarkupType) openrtb_ext.BidType { |
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.
@scr-oath are you asking if there is a helper function offered that can be used by any adapter? There isn't. We might be able to offer that at some point but we should keep in mind that not all adapters support the same media types and the default case will vary. Also some adapters will fall back to deriving the media type from the request imp if mtype
is not in the response.
ext := pbsExt{} | ||
err = jsonutil.Unmarshal(request.Imp[0].Ext, &ext) | ||
if err != nil { | ||
return nil, []error{err} |
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.
Please add a supplemental test case where the unmarshal fails. You can do this by simply setting your imp.ext
to a type other than object.
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.
Done
…ere unmarshal fails
Code coverage summaryNote:
omsRefer here for heat map coverage report
|
adapters/oms/oms.go
Outdated
type pbsExt struct { | ||
Bidder genericPID `json:"bidder"` | ||
Tid string `json:"tid"` | ||
} | ||
|
||
type genericPID struct { | ||
Pid string `json:"pid"` | ||
PublisherID int `json:"publisherId"` | ||
} | ||
|
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.
These new types are not needed here.
You will need to add new field to ExtImpOms
, it already exists in the openrtb_ext directory:
type ExtImpOms struct {
Pid string `json:"pid"`
PublisherID int `json:"publisherId"`
}
And then in MakeRequests follow a general approach to Unmarshal imp.ext:
example
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.
Done
Code coverage summaryNote:
omsRefer here for heat map coverage report
|
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.
LGTM
No description provided.