runnerpool

package
v0.3.678 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

The consistent hash ring from the original fnlb.

The behaviour of this depends on changes to the runner list leaving it relatively stable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPlacerTracker

func NewPlacerTracker(requestCtx context.Context, cfg *PlacerConfig, call RunnerCall) *placerTracker

func RegisterPlacerViews

func RegisterPlacerViews(tagKeys []string, latencyDist []float64)

Types

type Placer

type Placer interface {
	PlaceCall(ctx context.Context, rp RunnerPool, call RunnerCall) error
	GetPlacerConfig() PlacerConfig
}

Placer implements a placement strategy for calls that are load-balanced across runners in a pool

func NewCHPlacer

func NewCHPlacer(cfg *PlacerConfig) Placer

func NewFakeDetachedPlacer

func NewFakeDetachedPlacer(cfg *PlacerConfig, st time.Duration) Placer

func NewNaivePlacer

func NewNaivePlacer(cfg *PlacerConfig) Placer

type PlacerConfig

type PlacerConfig struct {
	// After all runners in the runner list is tried, apply a delay before retrying.
	RetryAllDelay time.Duration `json:"retry_all_delay"`

	// Maximum amount of time a placer can hold a request during runner attempts
	PlacerTimeout time.Duration `json:"placer_timeout"`

	// Maximum amount of time a placer can hold an ack sync request during runner attempts
	DetachedPlacerTimeout time.Duration `json:"detached_placer_timeout"`
}

Common config for placers.

func NewPlacerConfig

func NewPlacerConfig() PlacerConfig

type Runner

type Runner interface {
	TryExec(ctx context.Context, call RunnerCall) (bool, error)
	Status(ctx context.Context) (*RunnerStatus, error)
	Close(ctx context.Context) error
	Address() string
}

Runner is the interface to invoke the execution of a function call on a specific runner

type RunnerCall

type RunnerCall interface {
	SlotHashId() string
	Extensions() map[string]string
	RequestBody() io.ReadCloser
	ResponseWriter() http.ResponseWriter
	StdErr() io.ReadWriteCloser
	Model() *models.Call
	// For metrics/stats, add special accounting for time spent in customer code
	AddUserExecutionTime(dur time.Duration)
	GetUserExecutionTime() *time.Duration
}

RunnerCall provides access to the necessary details of request in order for it to be processed by a RunnerPool

type RunnerPool

type RunnerPool interface {
	// returns an error for unrecoverable errors that should not be retried
	Runners(ctx context.Context, call RunnerCall) ([]Runner, error)
	Shutdown(ctx context.Context) error
}

RunnerPool is the abstraction for getting an ordered list of runners to try for a call

type RunnerStatus

type RunnerStatus struct {
	ActiveRequestCount int32           // Number of active running requests on Runner
	RequestsReceived   uint64          // Number of requests received by Runner
	RequestsHandled    uint64          // Number of requests handled without NACK by Runner
	KdumpsOnDisk       uint64          // Number of kdumps on disk
	StatusFailed       bool            // True if Status execution failed
	Cached             bool            // True if Status was provided from cache
	StatusId           string          // Call ID for Status
	Details            string          // General/Debug Log information
	ErrorCode          int32           // If StatusFailed, then error code is set
	ErrorStr           string          // Error details if StatusFailed and ErrorCode is set
	CreatedAt          common.DateTime // Status creation date at Runner
	StartedAt          common.DateTime // Status execution date at Runner
	CompletedAt        common.DateTime // Status completion date at Runner
	SchedulerDuration  time.Duration   // Amount of time runner scheduler spent on the request
	ExecutionDuration  time.Duration   // Amount of time runner spent on function execution
	IsNetworkDisabled  bool            // True if network on runner is offline
}

RunnerStatus is general information on Runner health as returned by Runner::Status() call

Jump to

Keyboard shortcuts

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