Version: v0.177.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 15 Imported by: 108




This section is empty.


View Source
var DefaultHTTPAdapterConfig = &HTTPAdapterConfig{
	MaxConns:        50,
	MaxConnsPerHost: 10,
	IdleConnTimeout: 60 * time.Second,

DefaultHTTPAdapterConfig is an HTTPAdapterConfig that chooses sensible default values.


func MakeOpenRTBGeneric

func MakeOpenRTBGeneric(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bidderFamily string, allowedMediatypes []pbs.MediaType) (openrtb2.BidRequest, error)

adapters.MakeOpenRTBGeneric makes an openRTB request from the PBS-specific structs.

Any objects pointed to by the returned BidRequest *must not be mutated*, or we will get race conditions. The only exception is the Imp property, whose objects will be created new by this method and can be mutated freely.


type Adapter

type Adapter interface {
	// Name must be identical to the BidderName.
	Name() string
	// Determines whether this adapter should get callouts if there is not a synched user ID.
	SkipNoCookies() bool
	// Call produces bids which should be considered, given the auction params.
	// In practice, implementations almost always make one call to an external server here.
	// However, that is not a requirement for satisfying this interface.
	// An error here will cause all bids to be ignored. If the error was caused by bad user input,
	// this should return a BadInputError. If it was caused by bad server behavior
	// (e.g. 500, unexpected response format, etc), this should return a BadServerResponseError.
	Call(ctx context.Context, req *pbs.PBSRequest, bidder *pbs.PBSBidder) (pbs.PBSBidSlice, error)

Adapter is a deprecated interface which connects prebid-server to a demand partner. PBS is currently being rewritten to use Bidder, and this will be removed after. Their primary purpose is to produce bids in response to Auction requests.

type Bidder

type Bidder interface {
	// MakeRequests makes the HTTP requests which should be made to fetch bids.
	// Bidder implementations can assume that the incoming BidRequest has:
	//   1. Only {Imp.Type, Platform} combinations which are valid, as defined by the static/bidder-info.{bidder}.yaml file.
	//   2. Imp.Ext of the form {"bidder": params}, where "params" has been validated against the static/bidder-params/{bidder}.json JSON Schema.
	// nil return values are acceptable, but nil elements *inside* those slices are not.
	// The errors should contain a list of errors which explain why this bidder's bids will be
	// "subpar" in some way. For example: the request contained ad types which this bidder doesn't support.
	// If the error is caused by bad user input, return an errortypes.BadInput.
	MakeRequests(request *openrtb2.BidRequest, reqInfo *ExtraRequestInfo) ([]*RequestData, []error)

	// MakeBids unpacks the server's response into Bids.
	// The bids can be nil (for no bids), but should not contain nil elements.
	// The errors should contain a list of errors which explain why this bidder's bids will be
	// "subpar" in some way. For example: the server response didn't have the expected format.
	// If the error was caused by bad user input, return a errortypes.BadInput.
	// If the error was caused by a bad server response, return a errortypes.BadServerResponse
	MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *RequestData, response *ResponseData) (*BidderResponse, []error)

Bidder describes how to connect to external demand.

func BuildInfoAwareBidder

func BuildInfoAwareBidder(bidder Bidder, info config.BidderInfo) Bidder

BuildInfoAwareBidder wraps a bidder to enforce site, app, and media type support.

type BidderResponse

type BidderResponse struct {
	Currency string
	Bids     []*TypedBid

BidderResponse wraps the server's response with the list of bids and the currency used by the bidder.

Currency declaration is not mandatory but helps to detect an eventual currency mismatch issue. From the bid response, the bidder accepts a list of valid currencies for the bid. The currency is the same across all bids.

func NewBidderResponse

func NewBidderResponse() *BidderResponse

NewBidderResponse create a new BidderResponse initialising the bids array and the default currency value to "USD".

By default, Bids capacity will be set to 0. By default, currency is USD but this behavior might be subject to change.

func NewBidderResponseWithBidsCapacity

func NewBidderResponseWithBidsCapacity(bidsCapacity int) *BidderResponse

NewBidderResponseWithBidsCapacity create a new BidderResponse initialising the bids array capacity and the default currency value to "USD".

bidsCapacity allows to set initial Bids array capacity. By default, currency is USD but this behavior might be subject to change.

type Builder

type Builder func(openrtb_ext.BidderName, config.Adapter) (Bidder, error)

type CallOneResult

type CallOneResult struct {
	StatusCode   int
	ResponseBody string
	Bid          *pbs.PBSBid
	Error        error

used for callOne (possibly pull all of the shared code here)

type ExtImpBidder

type ExtImpBidder struct {
	Prebid *openrtb_ext.ExtImpPrebid `json:"prebid"`

	// Bidder contain the bidder-specific extension. Each bidder should unmarshal this using their
	// corresponding openrtb_ext.ExtImp{Bidder} struct.
	// For example, the Appnexus Bidder should unmarshal this with an openrtb_ext.ExtImpAppnexus object.
	// Bidder implementations may safely assume that this JSON has been validated by their
	// static/bidder-params/{bidder}.json file.
	Bidder json.RawMessage `json:"bidder"`

ExtImpBidder can be used by Bidders to unmarshal any request.imp[i].ext.

type ExtraRequestInfo

type ExtraRequestInfo struct {
	PbsEntryPoint              metrics.RequestType
	GlobalPrivacyControlHeader string
	CurrencyConversions        currency.Conversions

func NewExtraRequestInfo added in v0.166.0

func NewExtraRequestInfo(c currency.Conversions) ExtraRequestInfo

func (ExtraRequestInfo) ConvertCurrency added in v0.166.0

func (r ExtraRequestInfo) ConvertCurrency(value float64, from, to string) (float64, error)

ConvertCurrency converts a given amount from one currency to another, or returns:

- Error if the `from` or `to` arguments are malformed or unknown ISO-4217 codes.
- ConversionNotFoundError if the conversion mapping is unknown to Prebid Server
  and not provided in the bid request.

type HTTPAdapter

type HTTPAdapter struct {
	Client *http.Client

func NewHTTPAdapter

func NewHTTPAdapter(c *HTTPAdapterConfig) *HTTPAdapter

NewHTTPAdapter creates an HTTPAdapter which obeys the rules given by the config, and has all the available SSL certs available in the project.

type HTTPAdapterConfig

type HTTPAdapterConfig struct {
	// See IdleConnTimeout on
	IdleConnTimeout time.Duration
	// See MaxIdleConns on
	MaxConns int
	// See MaxIdleConnsPerHost on
	MaxConnsPerHost int

HTTPAdapterConfig groups options which control how HTTP requests are made by adapters.

type InfoAwareBidder

type InfoAwareBidder struct {
	// contains filtered or unexported fields

InfoAwareBidder wraps a Bidder to ensure all requests abide by the capabilities and media types defined in the static/bidder-info/{bidder}.yaml file.

It adjusts incoming requests in the following ways:

1. If App or Site traffic is not supported by the info file, then requests from
   those sources will be rejected before the delegate is called.
2. If a given MediaType is not supported for the platform, then it will be set
   to nil before the request is forwarded to the delegate.
3. Any Imps which have no MediaTypes left will be removed.
4. If there are no valid Imps left, the delegate won't be called at all.

func (*InfoAwareBidder) MakeRequests

func (i *InfoAwareBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *ExtraRequestInfo) ([]*RequestData, []error)

type MisconfiguredAdapter

type MisconfiguredAdapter struct {
	TheName string
	Err     error

func (*MisconfiguredAdapter) Call

func (*MisconfiguredAdapter) Name

func (b *MisconfiguredAdapter) Name() string

func (*MisconfiguredAdapter) SkipNoCookies

func (b *MisconfiguredAdapter) SkipNoCookies() bool

type RequestData

type RequestData struct {
	Method  string
	Uri     string
	Body    []byte
	Headers http.Header

RequestData packages together the fields needed to make an http.Request.

func (*RequestData) SetBasicAuth

func (r *RequestData) SetBasicAuth(username string, password string)

type ResponseData

type ResponseData struct {
	StatusCode int
	Body       []byte
	Headers    http.Header

ResponseData packages together information from the server's http.Response.

type TimeoutBidder

type TimeoutBidder interface {

	// MakeTimeoutNotice functions much the same as MakeRequests, except it is fed the bidder request that timed out,
	// and expects that only one notification "request" will be generated. A use case for multiple timeout notifications
	// has not been anticipated.
	// Do note that if MakeRequests returns multiple requests, and more than one of these times out, MakeTimeoutNotice will be called
	// once for each timed out request.
	MakeTimeoutNotification(req *RequestData) (*RequestData, []error)

TimeoutBidder is used to identify bidders that support timeout notifications.

type TypedBid

type TypedBid struct {
	Bid          *openrtb2.Bid
	BidMeta      *openrtb_ext.ExtBidPrebidMeta
	BidType      openrtb_ext.BidType
	BidVideo     *openrtb_ext.ExtBidPrebidVideo
	DealPriority int

TypedBid packages the openrtb2.Bid with any bidder-specific information that PBS needs to populate an openrtb_ext.ExtBidPrebid.

TypedBid.Bid.Ext will become "response.seatbid[i].bid.ext.bidder" in the final OpenRTB response. TypedBid.BidMeta will become "response.seatbid[i].bid.ext.prebid.meta" in the final OpenRTB response. TypedBid.BidType will become "response.seatbid[i].bid.ext.prebid.type" in the final OpenRTB response. TypedBid.BidVideo will become "response.seatbid[i]" in the final OpenRTB response. TypedBid.DealPriority is optionally provided by adapters and used internally by the exchange to support deal targeted campaigns.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL