hookexecution

package
v0.236.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointAuction = "/openrtb2/auction"
	EndpointAmp     = "/openrtb2/amp"
)

Variables

This section is empty.

Functions

func NewHookExecutor

func NewHookExecutor(builder hooks.ExecutionPlanBuilder, endpoint string, me metrics.MetricsEngine) *hookExecutor

Types

type Action

type Action string

Action indicates the type of taken behaviour after the successful hook execution.

const (
	ActionUpdate Action = "update"    // the hook returned mutations that were successfully applied
	ActionReject Action = "reject"    // the hook decided to reject the stage
	ActionNone   Action = "no_action" // the hook does not want to take any action
)

type EmptyHookExecutor

type EmptyHookExecutor struct{}

func (*EmptyHookExecutor) ExecuteEntrypointStage

func (executor *EmptyHookExecutor) ExecuteEntrypointStage(_ *http.Request, body []byte) ([]byte, *RejectError)

func (*EmptyHookExecutor) ExecuteRawAuctionStage added in v0.236.0

func (executor *EmptyHookExecutor) ExecuteRawAuctionStage(body []byte) ([]byte, *RejectError)

func (*EmptyHookExecutor) GetOutcomes

func (executor *EmptyHookExecutor) GetOutcomes() []StageOutcome

func (*EmptyHookExecutor) SetAccount

func (executor *EmptyHookExecutor) SetAccount(_ *config.Account)

type ExecutionTime

type ExecutionTime struct {
	ExecutionTimeMillis time.Duration `json:"execution_time_millis"`
}

type FailureError

type FailureError struct {
	Message string
}

FailureError indicates expected error occurred during hook execution on the module-side. A moduleFailed metric will be sent in such case.

func (FailureError) Error

func (e FailureError) Error() string

type GroupOutcome

type GroupOutcome struct {
	// ExecutionTime is set to the longest ExecutionTime of its children.
	ExecutionTime
	InvocationResults []HookOutcome `json:"invocation_results"`
}

GroupOutcome represents the result of executing specific group of hooks.

type HookID

type HookID struct {
	ModuleCode   string `json:"module_code"`
	HookImplCode string `json:"hook_impl_code"`
}

HookID points to the specific hook defined by the hook execution plan.

type HookOutcome

type HookOutcome struct {
	// ExecutionTime is the execution time of a specific hook without applying its result.
	ExecutionTime
	AnalyticsTags hookanalytics.Analytics `json:"analytics_tags"`
	HookID        HookID                  `json:"hook_id"`
	Status        Status                  `json:"status"`
	Action        Action                  `json:"action"`
	Message       string                  `json:"message"` // arbitrary string value returned from hook execution
	DebugMessages []string                `json:"debug_messages"`
	Errors        []string                `json:"-"`
	Warnings      []string                `json:"-"`
}

HookOutcome represents the result of executing specific hook.

type HookStageExecutor

type HookStageExecutor interface {
	StageExecutor
	SetAccount(account *config.Account)
	GetOutcomes() []StageOutcome
}

type RejectError

type RejectError struct {
	NBR   int
	Hook  HookID
	Stage string
}

RejectError indicates stage rejection requested by specific hook. Implements errortypes.Coder interface for compatibility only, so as not to be recognized as a fatal error

func CastRejectErr

func CastRejectErr(err error) (*RejectError, bool)

func FindFirstRejectOrNil

func FindFirstRejectOrNil(errors []error) *RejectError

func (RejectError) Code

func (e RejectError) Code() int

func (RejectError) Error

func (e RejectError) Error() string

func (RejectError) Severity

func (e RejectError) Severity() errortypes.Severity

type StageExecutor

type StageExecutor interface {
	ExecuteEntrypointStage(req *http.Request, body []byte) ([]byte, *RejectError)
	ExecuteRawAuctionStage(body []byte) ([]byte, *RejectError)
}

type StageOutcome

type StageOutcome struct {
	// ExecutionTime is the sum of ExecutionTime of all its groups
	ExecutionTime
	// An Entity specifies the type of object that was processed during the execution of the stage.
	Entity entity         `json:"entity"`
	Groups []GroupOutcome `json:"groups"`
	Stage  string         `json:"-"`
}

StageOutcome represents the result of executing specific stage.

type Status

type Status string

Status indicates the result of hook execution.

const (
	StatusSuccess          Status = "success"           // successful hook execution
	StatusTimeout          Status = "timeout"           // hook was not completed in the allotted time
	StatusFailure          Status = "failure"           // expected module-side failure occurred during hook execution
	StatusExecutionFailure Status = "execution_failure" // unexpected failure occurred during hook execution
)

type TimeoutError

type TimeoutError struct{}

TimeoutError indicates exceeding of the max execution time allotted for hook.

func (TimeoutError) Error

func (e TimeoutError) Error() string

Jump to

Keyboard shortcuts

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