api

package
v0.0.0-...-d691e2b Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTypeNone = "None"
	LogTypeTail = "Tail"
)
View Source
const (
	InvokeTypeCommon      InvokeType = "common"
	InvokeTypeEvent                  = "event"
	InvokeTypeStream                 = "stream"
	InvokeTypeHttpTrigger            = "httpTrigger"
	InvokeTypeMqhub                  = "mqhub"
)
View Source
const (
	TriggerTypeHTTP    TriggerType = "faas-http-trigger"
	TriggerTypeCrontab             = "faas-crontab-trigger"
	TriggerTypeKafka               = "kafka"
	TriggerTypeVscode              = "vscode"
	TriggerTypeGeneric             = "generic"
)
View Source
const (
	RunningModeCommon = "common"
	RunningModeIDE    = "ide"
)
View Source
const (
	TmpStorageTypeLoop     = "loop"
	TmpStorageTypeHostPath = "host-path"
)
View Source
const (
	RuntimeViaWarm    = "warm"
	RuntimeViaCold    = "cold"
	RuntimeViaUnknown = "unknown"
)
View Source
const (
	HeaderXRequestID    = "X-easyfaas-Request-Id"
	HeaderXAccountID    = "X-easyfaas-Account-Id"
	HeaderAuthorization = "Authorization"
	AppNameKey          = "app"
	HeaderInvokeType    = "X-easyfaas-Invoke-Type"
	HeaderLogType       = "Log-Type"
	HeaderLogToBody     = "Log-To-Body"
	HeaderXAuthToken    = "X-Auth-Token"

	BceFaasUIDKey          = "BCE-FAAS-UID"
	BceFaasTriggerKey      = "X-easyfaas-Faas-Trigger"
	XBceFunctionError      = "X-easyfaas-Function-Error"
	HeadereasyfaasExecTime = "X-easyfaas-Function-Exectime"
	HeaderLogResult        = "X-Bce-Log-Result"

	QueryLogType   = "logType"
	QueryLogToBody = "logToBody"
)
View Source
const (
	ContainerIDsParams = "ContainerIDs"
)
View Source
const MinMemorySize int64 = 128

Variables

View Source
var (
	RegfunctionName = regexp.MustCompile("^[a-zA-Z0-9-_]+$")
	RegVersion      = regexp.MustCompile("^(\\$LATEST|([0-9]+))$")
)

Functions

func GetLogToBody

func GetLogToBody(c *routing.Context) bool

func IsNoneLogType

func IsNoneLogType(logType string) bool

Types

type Alias

type Alias struct {
	Id                      uint `json:"-"`
	AliasBrn                string
	AliasArn                string
	FunctionName            string
	FunctionVersion         string
	Name                    string
	Description             *string
	Uid                     string
	UpdatedAt               time.Time
	CreatedAt               time.Time
	AdditionalVersion       *string
	AdditionalVersionWeight *float64
}

type CPUStats

type CPUStats struct {
	TotalUsage int64
}

type CodeStorage

type CodeStorage struct {
	Location       string
	RepositoryType string
}

CodeStorage

type Concurrency

type Concurrency struct {
	lambda.PutFunctionConcurrencyOutput
	AccountReservedSum int
}

Concurrency xxx

type ContainerInfo

type ContainerInfo struct {
	Hostname       string
	ContainerID    string
	HostPid        int
	EventLock      EventLock
	CurrentEvent   Event
	WithStreamMode bool
	IsFrozen       bool
	Resource       *Resource
	ResourceStats  *ResourceStats
}

func (*ContainerInfo) Copy

func (c *ContainerInfo) Copy() (nc *ContainerInfo)

func (*ContainerInfo) MarshalLogObject

func (c *ContainerInfo) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject is marshaler for ContainerInfo

type ContainerInfoResponse

type ContainerInfoResponse = ContainerInfo

type CoolDownRequest

type CoolDownRequest struct {
	ContainerID             string
	RequestID               string
	ScaleDownRecommendation *ScaleDownRecommendation
}

type Environment

type Environment struct {
	Variables map[string]string
}

Function Environment

type Event

type Event string
const (
	EventInit   Event = "event_init"
	EventWarmup Event = "event_warmup"
	EventReset  Event = "event_reset"
)

type EventLock

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

func NewEventLock

func NewEventLock() EventLock

func (EventLock) Lock

func (l EventLock) Lock() bool

func (EventLock) UnLock

func (l EventLock) UnLock()

type FreezerState

type FreezerState string
const (
	Undefined FreezerState = ""
	Frozen    FreezerState = "FROZEN"
	Thawed    FreezerState = "THAWED"
)

type FuncletClientContainerInfoInput

type FuncletClientContainerInfoInput struct {
	RequestID string
	ID        string
}

type FuncletClientCoolDownInput

type FuncletClientCoolDownInput struct {
	Host                    string
	ContainerID             string
	RequestID               string
	ScaleDownRecommendation *ScaleDownRecommendation
}

type FuncletClientListContainersInput

type FuncletClientListContainersInput struct {
	Host      string
	Criteria  *ListContainerCriteria
	RequestID string
}

type FuncletClientListNodeInput

type FuncletClientListNodeInput struct {
	RequestID string
}

type FuncletClientRebornInput

type FuncletClientRebornInput struct {
	ContainerID             string
	RequestID               string
	ScaleDownRecommendation *ScaleDownRecommendation
}

type FuncletClientWarmUpInput

type FuncletClientWarmUpInput struct {
	ContainerID           string
	RequestID             string
	Code                  *FunctionCodeLocation
	Configuration         *FunctionConfiguration
	RuntimeConfiguration  *RuntimeConfiguration
	NeedScaleUp           bool
	ScaleUpRecommendation *ScaleUpRecommendation
	WithStreamMode        bool // TODO: remove it after apiserver deployed in production
}

type FuncletNodeInfo

type FuncletNodeInfo struct {
	Resource *FuncletResource
}

type FuncletResource

type FuncletResource struct {
	BaseMemory  uint64
	Default     *Resource
	Capacity    *Resource
	Reserved    *Resource
	Allocatable *Resource
}

func NewFuncletResource

func NewFuncletResource() *FuncletResource

type FunctionCodeLocation

type FunctionCodeLocation struct {
	lambda.FunctionCodeLocation
	LogType string
}

FunctionCodeLocation

type FunctionConfig

type FunctionConfig struct {
	CodeSha256   string
	CodeSize     int32
	FunctionArn  string
	FunctionName string
	Handler      string
	Version      string
	Runtime      string
	MemorySize   *int
	Timeout      *int
	Environment  *Environment
	CommitID     *string `json:"CommitId"`

	LogType   string `json:",omitempty"`
	LogBosDir string `json:",omitempty"`

	PodConcurrentQuota *int `json:"PodConcurrentQuota"`
}

FunctionConfig

type FunctionConfiguration

type FunctionConfiguration struct {
	lambda.FunctionConfiguration
	CommitID           *string `json:"CommitId,omitempty"`
	Uid                string  `json:",omitempty"`
	LogType            string  `json:",omitempty"`
	LogBosDir          string  `json:",omitempty"`
	PodConcurrentQuota uint64  `json:",omitempty"`
}

FunctionConfiguration

func (*FunctionConfiguration) SetCommitID

func (*FunctionConfiguration) String

func (s *FunctionConfiguration) String() string

type GetAliasInput

type GetAliasInput struct {
	FunctionBrn   string
	FunctionName  string
	Qualifier     string
	Authorization string
	RequestID     string
	AccountID     string
	WithCache     bool
	SimpleAuth    bool
}

GetFunctionInput

type GetAliasOutput

type GetAliasOutput = Alias

type GetFunctionInput

type GetFunctionInput struct {
	Authorization string
	lambda.GetFunctionInput
	RequestID  string
	AccountID  string
	WithCache  bool
	SimpleAuth bool
}

GetFunctionInput

type GetFunctionOutput

type GetFunctionOutput struct {

	// The object for the Lambda function location.
	Code *FunctionCodeLocation `type:"structure"`

	// The concurrent execution limit set for this function. For more information,
	// see concurrent-executions.
	Concurrency *Concurrency `type:"structure",json:",omitempty"`

	// A complex type that describes function metadata.
	Configuration *FunctionConfiguration `type:"structure"`
	LogConfig     *LogConfiguration      `type:"structure",json:",omitempty"`

	Uid                string  `json:",omitempty"`
	LogType            string  `json:",omitempty"`
	PodConcurrentQuota *uint64 `json:",omitempty"`
	// Returns the list of tags associated with the function.
	Tags map[string]*string `type:"map",json:",omitempty"`
}

GetFunctionOutput

type GetRuntimeConfigurationInput

type GetRuntimeConfigurationInput struct {
	Authorization string
	RuntimeName   string
	RequestID     string
}

GetFunctionInput

type InvokeHeaders

type InvokeHeaders map[string]string

func (InvokeHeaders) Get

func (h InvokeHeaders) Get(k string) string

func (InvokeHeaders) Set

func (h InvokeHeaders) Set(k, v string)

type InvokeProxyRequest

type InvokeProxyRequest struct {
	Headers         map[string]string
	Body            []byte
	BodyStream      io.ReadWriter
	IsBase64Encoded bool
}

func NewInvokeProxyRequest

func NewInvokeProxyRequest(headers map[string]string, body []byte, bodyStream io.ReadWriter) *InvokeProxyRequest

func (*InvokeProxyRequest) SetBody

func (ir *InvokeProxyRequest) SetBody(msg []byte)

func (*InvokeProxyRequest) SetHeader

func (ir *InvokeProxyRequest) SetHeader(k string, v string)

type InvokeProxyResponse

type InvokeProxyResponse struct {
	StatusCode      int
	Headers         map[string]string
	Body            []byte
	BodyStream      io.ReadCloser
	IsBase64Encoded bool
}

func NewInvokeProxyResponse

func NewInvokeProxyResponse() *InvokeProxyResponse

func NewInvokeProxyResponseWithRequestID

func NewInvokeProxyResponseWithRequestID(requestID string) *InvokeProxyResponse

func (*InvokeProxyResponse) SetBody

func (ir *InvokeProxyResponse) SetBody(msg []byte)

func (*InvokeProxyResponse) SetHeader

func (ir *InvokeProxyResponse) SetHeader(k string, v string)

func (*InvokeProxyResponse) SetStatusCode

func (ir *InvokeProxyResponse) SetStatusCode(c int)

type InvokeRequest

type InvokeRequest struct {
	UserID         string
	Authorization  string
	FunctionName   string
	Qualifier      string
	FunctionBRN    string
	Queries        url.Values
	Headers        InvokeHeaders
	Body           *string
	BodyStream     io.ReadWriter
	WithBodyStream bool
	LogToBody      bool
	LogType        LogType
	RequestID      string
	InvokeType     string
	TriggerType    string
}

type InvokeResponse

type InvokeResponse struct {
	IsBase64Encoded bool
	// contains filtered or unexported fields
}

func NewInvokeResponse

func NewInvokeResponse() *InvokeResponse

func (*InvokeResponse) Body

func (iresp *InvokeResponse) Body() []byte

func (*InvokeResponse) BodyStream

func (iresp *InvokeResponse) BodyStream() io.ReadCloser

func (*InvokeResponse) BodyString

func (iresp *InvokeResponse) BodyString() *string

func (*InvokeResponse) GetHeader

func (iresp *InvokeResponse) GetHeader(k string) (v string, ok bool)

func (*InvokeResponse) Headers

func (iresp *InvokeResponse) Headers() *map[string]string

func (*InvokeResponse) SetBody

func (iresp *InvokeResponse) SetBody(b []byte)

func (*InvokeResponse) SetBodyStream

func (iresp *InvokeResponse) SetBodyStream(bs io.ReadCloser)

func (*InvokeResponse) SetHeader

func (iresp *InvokeResponse) SetHeader(k, v string)

func (*InvokeResponse) SetHeaders

func (iresp *InvokeResponse) SetHeaders(hMap *map[string]string)

func (*InvokeResponse) SetStatusCode

func (iresp *InvokeResponse) SetStatusCode(c int)

func (*InvokeResponse) StatusCode

func (iresp *InvokeResponse) StatusCode() int

type InvokeType

type InvokeType = string

type ListContainerCriteria

type ListContainerCriteria struct {
	rest.QueryCriteria
}

func NewListContainerCriteria

func NewListContainerCriteria() *ListContainerCriteria

func (*ListContainerCriteria) AddContainerIDs

func (c *ListContainerCriteria) AddContainerIDs(IDs []string)

func (*ListContainerCriteria) ReadContainerIDs

func (c *ListContainerCriteria) ReadContainerIDs() (IDs []string, err error)

type ListContainersResponse

type ListContainersResponse []*ContainerInfo

type LogConfiguration

type LogConfiguration struct {
	LogType string

	// for bos
	BosDir string

	// for other
	Params string
}

func (LogConfiguration) String

func (c LogConfiguration) String() string

type LogType

type LogType string

func GetLogType

func GetLogType(c *routing.Context) LogType

func (LogType) IsLogTypeTail

func (t LogType) IsLogTypeTail() bool

IsLogTypeTail check if logtype is Tail

func (LogType) Valid

func (t LogType) Valid() bool

Valid check if logtype is valid

type MemoryStats

type MemoryStats struct {
	// Memory usage (in bytes).
	Usage int64
	// Memory limit (in bytes)
	Limit int64
	// MemorySwap Limit (in bytes)
	SwapLimit int64
}

MemoryStats holds the on-demand stastistics from the memory cgroup

type ProxyRequest

type ProxyRequest struct {
	HTTPMethod            string            `json:"httpMethod"`
	Headers               map[string]string `json:"headers"`
	QueryStringParameters map[string]string `json:"queryStringParameters"`
	Body                  string            `json:"body"`
}

type ProxyResponse

type ProxyResponse struct {
	IsBase64Encoded bool              `json:"isBase64Encoded"`
	StatusCode      int               `json:"statusCode"`
	Body            string            `json:"body"`
	Headers         map[string]string `json:"headers"`
}

type RebornRequest

type RebornRequest struct {
	ContainerID             string
	RequestID               string
	ScaleDownRecommendation *ScaleDownRecommendation
}

type ResetRequest

type ResetRequest struct {
	ContainerID             string
	RequestID               string
	ScaleDownRecommendation *ScaleDownRecommendation
}

type ResetResponse

type ResetResponse struct {
	ScaleDownResult *ScaleDownImplementationResult
}

func NewResetResponse

func NewResetResponse() *ResetResponse

type Resource

type Resource struct {
	MilliCPUs int64
	Memory    int64
}

func NewResource

func NewResource() *Resource

func (*Resource) Copy

func (r *Resource) Copy() *Resource

func (*Resource) String

func (r *Resource) String() string

func (*Resource) Sync

func (r *Resource) Sync(rs *Resource)

type ResourceStats

type ResourceStats struct {
	// Memory statistics.
	MemoryStats  *MemoryStats
	CPUStats     *CPUStats
	FreezerState FreezerState
}

ResourceStats holds on-demand stastistics from various cgroup subsystems

type RuntimeConfiguration

type RuntimeConfiguration struct {
	Name string
	Bin  string
	Path string
	Args []string
}

RuntimeConfiguration

type ScaleDownImplementationResult

type ScaleDownImplementationResult struct {
	Success []string
	Fails   map[string]*ContainerInfo
}

func NewScaleDownImplementationResult

func NewScaleDownImplementationResult() *ScaleDownImplementationResult

type ScaleDownRecommendation

type ScaleDownRecommendation struct {
	TargetContainer string
	ResetContainers []string
}

type ScaleUpRecommendation

type ScaleUpRecommendation struct {
	TargetMemory     string
	TargetContainer  string
	MergedContainers []string
}

type ServiceResource

type ServiceResource struct {
	Capacity    *Resource
	Allocatable *Resource
	Used        *Resource
	Marked      *Resource
	Default     *Resource
	BaseMemory  uint64
}

func (*ServiceResource) Copy

func (r *ServiceResource) Copy() *ServiceResource

type TriggerType

type TriggerType = string

type User

type User struct {
	// ID xxx
	ID string

	// AccessKeyID xxx
	AccessKeyID string

	// AccessKeySecret xxx
	AccessKeySecret string
}

User represent a user's credential

type WarmUpContainerArgs

type WarmUpContainerArgs struct {
	Code                  *CodeStorage
	Configuration         *FunctionConfig
	RuntimeConfiguration  *RuntimeConfiguration
	ScaleUpRecommendation *ScaleUpRecommendation
	WithStreamMode        bool // TODO: remove it after apiserver deployed in production
}

type WarmUpResponse

type WarmUpResponse struct {
	Container ContainerInfo
}

type WarmupRequest

type WarmupRequest struct {
	ContainerID string
	RequestID   string
	*WarmUpContainerArgs
}

Jump to

Keyboard shortcuts

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