controller

package
v0.0.0-...-e2f6afb Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package controller

Index

Constants

View Source
const (
	StageGetFunction metricStage = iota
	StageGetFunctionHitCache
	StageGetRuntimeConfiguration
	StageGetRuntimeConfigurationHitCache
	StageGetPodWarm
	StageGetPodCold
	StagePutPod
	StageInvocation
	StageAllCost
	StageStageSumUp
	StageSchedule
	StageOther
)
View Source
const (
	ResourceTypeLabel = "resource_type"
	RuntimeIDLabel    = "runtime_id"
)
View Source
const (
	MetricRuntimeInUse metricRuntime = iota
	MetricRuntimeCold
	MetricRuntimeAll
	RuntimeMemoryUsageBytes
	RuntimeCPUUsageSeconds
)
View Source
const (
	InvokeErrNoReason     = ""
	InvokeInvalidParam    = "invoke_invalid_param"
	InvokeTooManyRequests = "invoke_too_many_requests"
	InvokeRuntimeError    = "invoke_runtime_error"
)
View Source
const (
	ClientModeCommon      = "common"
	ClientModeInside      = "inside"
	ClientModeHTTPTrigger = "httpTrigger"
)

Variables

View Source
var (
	NoOutputMsg = "no output"
)

TODO: error

View Source
var RuntimeResourceLabels = []string{RuntimeIDLabel}

Functions

func RuntimeMetricName

func RuntimeMetricName(m metricRuntime) string

func StageName

func StageName(ms metricStage) string

Types

type Clients

type Clients struct {
	DataStorer     function.DataStorer
	RuntimeControl rtctrl.Control
	FuncletClient  client.FuncletInterface
}

Clients save all clients to make rpc calls

type Controller

type Controller struct {
	FuncletClient client.FuncletInterface
	// contains filtered or unexported fields
}

func Init

func Init(options *options.ControllerOptions) (controller *Controller, err error)

func (*Controller) Do

func (controller *Controller) Do(ctx *InvokeContext)

func (*Controller) GetResourceHandler

func (controller *Controller) GetResourceHandler(c *routing.Context) error

func (*Controller) HealthzHandler

func (controller *Controller) HealthzHandler(c *routing.Context) error

func (*Controller) InvalidateRuntime

func (controller *Controller) InvalidateRuntime(c *routing.Context) error

func (*Controller) Invoke

func (controller *Controller) Invoke(c *routing.Context, ctx InvokeContext)

func (*Controller) InvokeHandler

func (controller *Controller) InvokeHandler(c *routing.Context) error

func (*Controller) ListRuntimesHandler

func (controller *Controller) ListRuntimesHandler(c *routing.Context) error

func (*Controller) NewClients

func (controller *Controller) NewClients(clientMode string) *Clients

func (*Controller) SummaryMetrics

func (controller *Controller) SummaryMetrics(ctx *InvokeContext)

type ControllerInterface

type ControllerInterface interface {
	NewClients(string) *Clients
	Do(ctx *InvokeContext)
}

type InvokeContext

type InvokeContext struct {
	RunOptions *options.ControllerOptions

	ExternalRequestID string // RequestID from external request
	RequestID         string // System inner unique RequestID

	AccountID     string    // user account id from external request
	CallerUser    *api.User // credential user info of function's caller
	OwnerUser     *api.User // credential user info of function's owner
	Authorization string

	Function *api.GetFunctionOutput
	Runtime  *api.RuntimeConfiguration

	Input     *rtctrl.InvocationInput
	Output    *rtctrl.InvocationOutput
	Statistic *rtctrl.InvocationStatistic

	// controller invoke request
	Request *api.InvokeProxyRequest
	// controller invoke response
	Response *api.InvokeProxyResponse

	Logger  *logs.Logger
	Clients *Clients

	FunctionName string
	FunctionBRN  string
	Qualifier    string
	Brn          brn.BRN

	LogType   api.LogType
	LogToBody bool

	Metrics        *InvokeMetrics
	WithStreamMode bool

	InvokeType  string
	TriggerType string
}

type InvokeMetrics

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

func NewInvokeMetrics

func NewInvokeMetrics(reqID string) *InvokeMetrics

func (*InvokeMetrics) MarshalLogObject

func (i *InvokeMetrics) MarshalLogObject(enc zapcore.ObjectEncoder) error

func (*InvokeMetrics) Overall

func (i *InvokeMetrics) Overall()

func (*InvokeMetrics) ScrapStage

func (i *InvokeMetrics) ScrapStage(stage metricStage) error

func (*InvokeMetrics) SetLabel

func (i *InvokeMetrics) SetLabel(k, v string)

func (*InvokeMetrics) StepDone

func (i *InvokeMetrics) StepDone(stage metricStage) error

func (*InvokeMetrics) StepDoneWithLabel

func (i *InvokeMetrics) StepDoneWithLabel(stage metricStage, k, v string) error

func (*InvokeMetrics) StepStart

func (i *InvokeMetrics) StepStart(stage metricStage) error

func (*InvokeMetrics) WriteSummary

func (i *InvokeMetrics) WriteSummary(overheadMs int)

Directories

Path Synopsis
Package rtctrl Package rtctrl Package rtctrl Package rtctrl Package rtctrl Package rtctrl
Package rtctrl Package rtctrl Package rtctrl Package rtctrl Package rtctrl Package rtctrl

Jump to

Keyboard shortcuts

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