hooks

package
v2.32.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyPlanBuilder

type EmptyPlanBuilder struct{}

EmptyPlanBuilder implements the ExecutionPlanBuilder interface and used as the stub when the hooks' functionality is disabled.

func (EmptyPlanBuilder) PlanForAllProcessedBidResponsesStage

func (e EmptyPlanBuilder) PlanForAllProcessedBidResponsesStage(endpoint string, account *config.Account) Plan[hookstage.AllProcessedBidResponses]

func (EmptyPlanBuilder) PlanForAuctionResponseStage

func (e EmptyPlanBuilder) PlanForAuctionResponseStage(endpoint string, account *config.Account) Plan[hookstage.AuctionResponse]

func (EmptyPlanBuilder) PlanForBidderRequestStage

func (e EmptyPlanBuilder) PlanForBidderRequestStage(endpoint string, account *config.Account) Plan[hookstage.BidderRequest]

func (EmptyPlanBuilder) PlanForEntrypointStage

func (e EmptyPlanBuilder) PlanForEntrypointStage(endpoint string) Plan[hookstage.Entrypoint]

func (EmptyPlanBuilder) PlanForProcessedAuctionStage

func (e EmptyPlanBuilder) PlanForProcessedAuctionStage(endpoint string, account *config.Account) Plan[hookstage.ProcessedAuctionRequest]

func (EmptyPlanBuilder) PlanForRawAuctionStage

func (e EmptyPlanBuilder) PlanForRawAuctionStage(endpoint string, account *config.Account) Plan[hookstage.RawAuctionRequest]

func (EmptyPlanBuilder) PlanForRawBidderResponseStage

func (e EmptyPlanBuilder) PlanForRawBidderResponseStage(endpoint string, account *config.Account) Plan[hookstage.RawBidderResponse]

type ExecutionPlanBuilder

type ExecutionPlanBuilder interface {
	PlanForEntrypointStage(endpoint string) Plan[hookstage.Entrypoint]
	PlanForRawAuctionStage(endpoint string, account *config.Account) Plan[hookstage.RawAuctionRequest]
	PlanForProcessedAuctionStage(endpoint string, account *config.Account) Plan[hookstage.ProcessedAuctionRequest]
	PlanForBidderRequestStage(endpoint string, account *config.Account) Plan[hookstage.BidderRequest]
	PlanForRawBidderResponseStage(endpoint string, account *config.Account) Plan[hookstage.RawBidderResponse]
	PlanForAllProcessedBidResponsesStage(endpoint string, account *config.Account) Plan[hookstage.AllProcessedBidResponses]
	PlanForAuctionResponseStage(endpoint string, account *config.Account) Plan[hookstage.AuctionResponse]
}

ExecutionPlanBuilder is the interface that provides methods for retrieving hooks grouped and sorted in the established order according to the hook execution plan intended for run at a certain stage.

func NewExecutionPlanBuilder

func NewExecutionPlanBuilder(hooks config.Hooks, repo HookRepository) ExecutionPlanBuilder

NewExecutionPlanBuilder returns a new instance of the ExecutionPlanBuilder interface. Depending on the hooks' status, method returns a real PlanBuilder or the EmptyPlanBuilder.

type Group

type Group[T any] struct {
	// Timeout specifies the max duration in milliseconds that a group of hooks is allowed to run.
	Timeout time.Duration
	// Hooks holds a slice of HookWrapper of a specific type.
	Hooks []HookWrapper[T]
}

Group represents a slice of hooks sorted in the established order.

type HookRepository

type HookRepository interface {
	GetEntrypointHook(id string) (hookstage.Entrypoint, bool)
	GetRawAuctionHook(id string) (hookstage.RawAuctionRequest, bool)
	GetProcessedAuctionHook(id string) (hookstage.ProcessedAuctionRequest, bool)
	GetBidderRequestHook(id string) (hookstage.BidderRequest, bool)
	GetRawBidderResponseHook(id string) (hookstage.RawBidderResponse, bool)
	GetAllProcessedBidResponsesHook(id string) (hookstage.AllProcessedBidResponses, bool)
	GetAuctionResponseHook(id string) (hookstage.AuctionResponse, bool)
}

HookRepository is the interface that exposes methods that return instance of the certain hook interface.

Each method accepts hook ID and returns hook interface registered under this ID and true if hook found otherwise nil value returned with the false, indicating not found hook for this ID.

func NewHookRepository

func NewHookRepository(hooks map[string]interface{}) (HookRepository, error)

NewHookRepository returns a new instance of the HookRepository interface.

The hooks argument represents a mapping of hook IDs to types implementing at least one of the available hook interfaces, see hookstage pkg.

Error returned if provided interface doesn't implement any hook interface or hook with same ID already exists.

type HookWrapper

type HookWrapper[T any] struct {
	// Module holds a name of the module that provides the Hook.
	// Specified in the format "vendor.module_name".
	Module string
	// Code is an arbitrary value assigned to hook via the hook execution plan
	// and is used when sending metrics, logging debug information, etc.
	Code string
	// Hook is an instance of the specific hook interface.
	Hook T
}

HookWrapper wraps Hook representing specific hook interface and holds additional meta information, such as Module name and hook Code.

type Plan

type Plan[T any] []Group[T]

Plan represents a slice of groups of hooks of a specific type grouped in the established order.

type PlanBuilder

type PlanBuilder struct {
	// contains filtered or unexported fields
}

PlanBuilder is a concrete implementation of the ExecutionPlanBuilder interface. Which returns hook execution plans for specific stage defined by the hook config.

func (PlanBuilder) PlanForAllProcessedBidResponsesStage

func (p PlanBuilder) PlanForAllProcessedBidResponsesStage(endpoint string, account *config.Account) Plan[hookstage.AllProcessedBidResponses]

func (PlanBuilder) PlanForAuctionResponseStage

func (p PlanBuilder) PlanForAuctionResponseStage(endpoint string, account *config.Account) Plan[hookstage.AuctionResponse]

func (PlanBuilder) PlanForBidderRequestStage

func (p PlanBuilder) PlanForBidderRequestStage(endpoint string, account *config.Account) Plan[hookstage.BidderRequest]

func (PlanBuilder) PlanForEntrypointStage

func (p PlanBuilder) PlanForEntrypointStage(endpoint string) Plan[hookstage.Entrypoint]

func (PlanBuilder) PlanForProcessedAuctionStage

func (p PlanBuilder) PlanForProcessedAuctionStage(endpoint string, account *config.Account) Plan[hookstage.ProcessedAuctionRequest]

func (PlanBuilder) PlanForRawAuctionStage

func (p PlanBuilder) PlanForRawAuctionStage(endpoint string, account *config.Account) Plan[hookstage.RawAuctionRequest]

func (PlanBuilder) PlanForRawBidderResponseStage

func (p PlanBuilder) PlanForRawBidderResponseStage(endpoint string, account *config.Account) Plan[hookstage.RawBidderResponse]

type Stage

type Stage string
const (
	StageEntrypoint               Stage = "entrypoint"
	StageRawAuctionRequest        Stage = "raw_auction_request"
	StageProcessedAuctionRequest  Stage = "processed_auction_request"
	StageBidderRequest            Stage = "bidder_request"
	StageRawBidderResponse        Stage = "raw_bidder_response"
	StageAllProcessedBidResponses Stage = "all_processed_bid_responses"
	StageAuctionResponse          Stage = "auction_response"
)

Names of the available stages.

func (Stage) IsRejectable

func (s Stage) IsRejectable() bool

func (Stage) String

func (s Stage) String() string

Directories

Path Synopsis
Package hookanalytics provides basic primitives for use by the hook modules.
Package hookanalytics provides basic primitives for use by the hook modules.

Jump to

Keyboard shortcuts

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