spec

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package spec provides the spec for FaaS.

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 `json:"syncInterval" jsonschema:"required,format=duration"`

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

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

	// Currently we only supports knative type faas provider, so this filed should be
	// "required" right now.
	Knative *Knative `json:"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   `json:"spec" jsonschema:"required"`
	Status *Status `json:"status" jsonschema:"required"`
	Fsm    *FSM    `json:"fsm,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 `json:"hostSuffix" jsonschema:"required"`
	NetworkLayerURL string `json:"networkLayerURL" jsonschema:"required,format=uri"`

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

Knative is the faas provider Knative.

type Spec

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

	RequestAdaptor *builder.RequestAdaptorSpec `json:"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            `json:"name" jsonschema:"required"`
	State   State             `json:"state" jsonschema:"required"`
	Event   Event             `json:"event" jsonschema:"required"`
	ExtData map[string]string `json:"extData,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