spec

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// FailedState is the failed state
	FailedState State = "failed"
	// InitialState is the init state
	InitialState State = "initial"
	// ActiveState is the active state
	ActiveState State = "active"
	// InactiveState is the inactive state
	InactiveState State = "inactive"

	// DestroyedState - only for keep fsm working
	DestroyedState State = "destroyed"

	// CreateEvent is the create event
	CreateEvent Event = "create"
	// StartEvent is the start event
	StartEvent Event = "start"
	// StopEvent is the stop event
	StopEvent Event = "stop"
	// UpdateEvent is the update event
	UpdateEvent Event = "update"
	// DeleteEvent is the delete event
	DeleteEvent Event = "delete"

	// ReadyEvent is the ready event
	ReadyEvent Event = "ready"
	// PendingEvent is the pending event
	PendingEvent Event = "pending"
	// ErrorEvent is the error event
	ErrorEvent Event = "error"
)
View Source
const (
	// AutoScaleMetricCPU is name of cpu metric
	AutoScaleMetricCPU = "cpu"
	// AutoScaleMetricConcurrency is the name of concurrency metric
	AutoScaleMetricConcurrency = "concurrency"
	// AutoScaleMetricRPS is the name of rps metric
	AutoScaleMetricRPS = "rps"

	// ProviderKnative is the FaaS provider Knative.
	ProviderKnative = "knative"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	// SyncInterval is the interval for reconciling local FaaSFunction state and FaaSProvider's.
	SyncInterval string `yaml:"syncInterval" jsonschema:"required,format=duration"`

	// Provider is the FaaSProvider.
	Provider string `yaml:"provider" jsonschema:"required"`

	// HTTPServer is the HTTP traffic gate for accepting ingress traffic.
	HTTPServer *httpserver.Spec `yaml:"httpServer" jsonschema:"required"`

	// Currently we only supports knative type faas provider, so this filed should be
	// "required" right now.
	Knative *Knative `yaml:"knative" jsonschema:"required"`
}

Admin describes the Function.

type Event

type Event string

Event is the event type generated by CLI or FaaSProvider.

type FSM

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

FSM function is a finite state machine for managing faas function.

func InitFSM

func InitFSM(state State) (*FSM, error)

InitFSM creates a finite state machine by given states

func (*FSM) Current

func (fsm *FSM) Current() State

Current gets FSM current state.

func (*FSM) Next

func (fsm *FSM) Next(event Event) error

Next turns the function status into properate state by given event.

type Function

type Function struct {
	Spec   *Spec   `yaml:"spec" jsonschema:"required"`
	Status *Status `yaml:"status" jsonschema:"required"`
	Fsm    *FSM    `yaml:"fsm" jsonschema:"omitempty"`
}

Function contains the FaaSFunction's spec ,runtime status with a build-in fsm.

func (*Function) Next

func (function *Function) Next(event Event) (updated bool, err error)

Next turns function's states into next states by given event.

type Knative

type Knative struct {
	HostSuffix      string `yaml:"hostSuffix" jsonschema:"required"`
	NetworkLayerURL string `yaml:"networkLayerURL" jsonschema:"required,format=uri"`

	Namespace string `yaml:"namespace" jsonschema:"omitempty"`
	Timeout   string `yaml:"timeout" jsonschema:"omitempty,format=duration"`
}

Knative is the faas provider Knative.

type Spec

type Spec struct {
	Name           string `yaml:"name" jsonschema:"required"`
	Image          string `yaml:"image" jsonschema:"required"`
	Port           int    `yaml:"port" jsonschema:"omitempty"`
	AutoScaleType  string `yaml:"autoScaleType" jsonschema:"required"`
	AutoScaleValue string `yaml:"autoScaleValue" jsonschema:"required"`
	MinReplica     int    `yaml:"minReplica" jsonschema:"omitempty"`
	MaxReplica     int    `yaml:"maxReplica" jsonschema:"omitempty"`
	LimitCPU       string `yaml:"limitCPU" jsonschema:"omitempty"`
	LimitMemory    string `yaml:"limitMemory" jsonschema:"omitempty"`
	RequestCPU     string `yaml:"requestCPU" jsonschema:"omitempty"`
	RequestMemory  string `yaml:"requestMemory" jsonschema:"omitempty"`

	RequestAdaptor *requestadaptor.Spec `yaml:"requestAdaptor" jsonschema:"required"`
}

Spec is the spec of FaaSFunction.

func (*Spec) Validate

func (spec *Spec) Validate() error

Validate valid FaaSFunction's spec.

type State

type State string

State is the FaaSFunction's state.

func InitState

func InitState() State

InitState returns the initial FSM state which is the `pending` state.

type Status

type Status struct {
	Name    string            `yaml:"name" jsonschema:"required"`
	State   State             `yaml:"state" jsonschema:"required"`
	Event   Event             `yaml:"event" jsonschema:"required"`
	ExtData map[string]string `yaml:"extData" jsonschema:"omitempty"`
}

Status is the status of faas function.

Jump to

Keyboard shortcuts

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