hookstage

package
v0.254.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllProcessedBidResponses

type AllProcessedBidResponses interface {
	HandleAllProcessedBidResponsesHook(
		context.Context,
		ModuleInvocationContext,
		AllProcessedBidResponsesPayload,
	) (HookResult[AllProcessedBidResponsesPayload], error)
}

AllProcessedBidResponses hooks are invoked over a list of all processed responses received from bidders before a winner is chosen.

At this stage, account config is available, so it can be configured at the account-level execution plan, the account-level module config is passed to hooks.

Rejection has no effect and is completely ignored at this stage.

type AllProcessedBidResponsesPayload

type AllProcessedBidResponsesPayload struct {
	Responses map[openrtb_ext.BidderName]*entities.PbsOrtbSeatBid
}

AllProcessedBidResponsesPayload consists of a list of all processed responses received from bidders. Hooks are allowed to modify payload object and discard bids using mutations.

type AuctionResponse

type AuctionResponse interface {
	HandleAuctionResponseHook(
		context.Context,
		ModuleInvocationContext,
		AuctionResponsePayload,
	) (HookResult[AuctionResponsePayload], error)
}

AuctionResponse hooks are invoked at the very end of request processing. The hooks are invoked even if the request was rejected at earlier stages.

At this stage, account config is available, so it can be configured at the account-level execution plan, the account-level module config is passed to hooks.

Rejection has no effect and is completely ignored at this stage.

type AuctionResponsePayload

type AuctionResponsePayload struct {
	BidResponse *openrtb2.BidResponse
}

AuctionResponsePayload consists of a final openrtb2.BidResponse object that will be sent back to the requester. Hooks are allowed to modify openrtb2.BidResponse object.

type BidderRequest added in v0.234.2

type BidderRequest interface {
	HandleBidderRequestHook(
		context.Context,
		ModuleInvocationContext,
		BidderRequestPayload,
	) (HookResult[BidderRequestPayload], error)
}

BidderRequest hooks are invoked for each bidder participating in auction.

At this stage, account config is available, so it can be configured at the account-level execution plan, the account-level module config is passed to hooks.

Rejection results in skipping the bidder's request.

type BidderRequestPayload added in v0.234.2

type BidderRequestPayload struct {
	BidRequest *openrtb2.BidRequest
	Bidder     string
}

BidderRequestPayload consists of the openrtb2.BidRequest object distilled for the particular bidder. Hooks are allowed to modify openrtb2.BidRequest using mutations.

type ChangeSet added in v0.234.2

type ChangeSet[T any] struct {
	// contains filtered or unexported fields
}

func (*ChangeSet[T]) AddMutation added in v0.234.2

func (c *ChangeSet[T]) AddMutation(fn MutationFunc[T], t MutationType, k ...string) *ChangeSet[T]

func (*ChangeSet[T]) BidderRequest added in v0.239.0

func (c *ChangeSet[T]) BidderRequest() ChangeSetBidderRequest[T]

func (*ChangeSet[T]) Mutations added in v0.234.2

func (c *ChangeSet[T]) Mutations() []Mutation[T]

func (*ChangeSet[T]) RawBidderResponse added in v0.239.0

func (c *ChangeSet[T]) RawBidderResponse() ChangeSetRawBidderResponse[T]

type ChangeSetBAdv added in v0.239.0

type ChangeSetBAdv[T any] struct {
	// contains filtered or unexported fields
}

func (ChangeSetBAdv[T]) Update added in v0.239.0

func (c ChangeSetBAdv[T]) Update(badv []string)

type ChangeSetBApp added in v0.239.0

type ChangeSetBApp[T any] struct {
	// contains filtered or unexported fields
}

func (ChangeSetBApp[T]) Update added in v0.239.0

func (c ChangeSetBApp[T]) Update(bapp []string)

type ChangeSetBCat added in v0.239.0

type ChangeSetBCat[T any] struct {
	// contains filtered or unexported fields
}

func (ChangeSetBCat[T]) Update added in v0.239.0

func (c ChangeSetBCat[T]) Update(bcat []string)

type ChangeSetBidderRequest added in v0.239.0

type ChangeSetBidderRequest[T any] struct {
	// contains filtered or unexported fields
}

func (ChangeSetBidderRequest[T]) BAdv added in v0.239.0

func (c ChangeSetBidderRequest[T]) BAdv() ChangeSetBAdv[T]

func (ChangeSetBidderRequest[T]) BApp added in v0.239.0

func (c ChangeSetBidderRequest[T]) BApp() ChangeSetBApp[T]

func (ChangeSetBidderRequest[T]) BCat added in v0.239.0

func (c ChangeSetBidderRequest[T]) BCat() ChangeSetBCat[T]

func (ChangeSetBidderRequest[T]) CatTax added in v0.239.0

func (c ChangeSetBidderRequest[T]) CatTax() ChangeSetCatTax[T]

type ChangeSetBids added in v0.239.0

type ChangeSetBids[T any] struct {
	// contains filtered or unexported fields
}

func (ChangeSetBids[T]) Update added in v0.239.0

func (c ChangeSetBids[T]) Update(bids []*adapters.TypedBid)

type ChangeSetCatTax added in v0.239.0

type ChangeSetCatTax[T any] struct {
	// contains filtered or unexported fields
}

func (ChangeSetCatTax[T]) Update added in v0.239.0

func (c ChangeSetCatTax[T]) Update(cattax adcom1.CategoryTaxonomy)

type ChangeSetRawBidderResponse added in v0.239.0

type ChangeSetRawBidderResponse[T any] struct {
	// contains filtered or unexported fields
}

func (ChangeSetRawBidderResponse[T]) Bids added in v0.239.0

type Entrypoint

type Entrypoint interface {
	HandleEntrypointHook(
		context.Context,
		ModuleInvocationContext,
		EntrypointPayload,
	) (HookResult[EntrypointPayload], error)
}

Entrypoint hooks are invoked at the very beginning of request processing.

At this stage, account config is not yet available, so it can only be defined as part of the host-level execution plan, the account-level module config is not available.

Rejection results in sending an empty BidResponse with the NBR code indicating the rejection reason.

type EntrypointPayload

type EntrypointPayload struct {
	Request *http.Request
	Body    []byte
}

EntrypointPayload consists of an HTTP request and a raw body of the openrtb2.BidRequest. For "/openrtb2/amp" endpoint the body is nil. Hooks are allowed to modify this data using mutations.

type HookResult

type HookResult[T any] struct {
	Reject        bool         // true value indicates rejection of the program execution at the specific stage
	NbrCode       int          // hook must provide NbrCode if the field Reject set to true
	Message       string       // holds arbitrary message added by hook
	ChangeSet     ChangeSet[T] // set of changes the module wants to apply to hook payload in case of successful execution
	Errors        []string
	Warnings      []string
	DebugMessages []string
	AnalyticsTags hookanalytics.Analytics
	ModuleContext ModuleContext // holds values that the module wants to pass to itself at later stages
}

HookResult represents the result of execution the concrete hook instance.

type ModuleContext added in v0.234.2

type ModuleContext map[string]interface{}

ModuleContext holds arbitrary data passed between module hooks at different stages. We use interface as we do not know exactly how the modules will use their inner context.

type ModuleInvocationContext added in v0.234.2

type ModuleInvocationContext struct {
	// AccountConfig represents module config rewritten at the account-level.
	AccountConfig json.RawMessage
	// Endpoint represents the path of the current endpoint.
	Endpoint string
	// ModuleContext holds values that the module passes to itself from the previous stages.
	ModuleContext ModuleContext
}

ModuleInvocationContext holds data passed to the module hook during invocation.

type Mutation added in v0.234.2

type Mutation[T any] struct {
	// contains filtered or unexported fields
}

func (Mutation[T]) Apply added in v0.234.2

func (m Mutation[T]) Apply(p T) (T, error)

func (Mutation[T]) Key added in v0.234.2

func (m Mutation[T]) Key() []string

func (Mutation[T]) Type added in v0.234.2

func (m Mutation[T]) Type() MutationType

type MutationFunc added in v0.239.0

type MutationFunc[T any] func(T) (T, error)

type MutationType added in v0.234.2

type MutationType int
const (
	MutationAdd MutationType = iota
	MutationUpdate
	MutationDelete
)

func (MutationType) String added in v0.234.2

func (mt MutationType) String() string

type ProcessedAuctionRequest added in v0.234.2

type ProcessedAuctionRequest interface {
	HandleProcessedAuctionHook(
		context.Context,
		ModuleInvocationContext,
		ProcessedAuctionRequestPayload,
	) (HookResult[ProcessedAuctionRequestPayload], error)
}

ProcessedAuctionRequest hooks are invoked after the request is parsed and enriched with additional data.

At this stage, account config is available, so it can be configured at the account-level execution plan, the account-level module config is passed to hooks.

Rejection results in sending an empty BidResponse with the NBR code indicating the rejection reason.

type ProcessedAuctionRequestPayload added in v0.234.2

type ProcessedAuctionRequestPayload struct {
	BidRequest *openrtb2.BidRequest
}

ProcessedAuctionRequestPayload consists of the openrtb2.BidRequest object. Hooks are allowed to modify openrtb2.BidRequest using mutations.

type RawAuctionRequest added in v0.234.2

type RawAuctionRequest interface {
	HandleRawAuctionHook(
		context.Context,
		ModuleInvocationContext,
		RawAuctionRequestPayload,
	) (HookResult[RawAuctionRequestPayload], error)
}

RawAuctionRequest hooks are invoked only for "/openrtb2/auction" endpoint after retrieving the account config, but before the request is parsed and any additions are made.

At this stage, account config is available, so it can be configured at the account-level execution plan, the account-level module config is passed to hooks.

Rejection results in sending an empty BidResponse with the NBR code indicating the rejection reason.

type RawAuctionRequestPayload added in v0.234.2

type RawAuctionRequestPayload []byte

RawAuctionRequestPayload represents a raw body of the openrtb2.BidRequest. Hooks are allowed to modify body using mutations.

type RawBidderResponse added in v0.234.2

type RawBidderResponse interface {
	HandleRawBidderResponseHook(
		context.Context,
		ModuleInvocationContext,
		RawBidderResponsePayload,
	) (HookResult[RawBidderResponsePayload], error)
}

RawBidderResponse hooks are invoked for each bidder participating in auction.

At this stage, account config is available, so it can be configured at the account-level execution plan, the account-level module config is passed to hooks.

Rejection results in ignoring the bidder's response.

type RawBidderResponsePayload added in v0.234.2

type RawBidderResponsePayload struct {
	Bids   []*adapters.TypedBid
	Bidder string
}

RawBidderResponsePayload consists of a list of adapters.TypedBid objects representing bids returned by a particular bidder. Hooks are allowed to modify bids using mutations.

Jump to

Keyboard shortcuts

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