types

package
v0.25.3 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 7 Imported by: 152

Documentation

Index

Constants

View Source
const (
	TypeFunctionUsage = "function_usage"
	TypeAPIAccess     = "api_access"
)

Variables

This section is empty.

Functions

func ParseBoolValue

func ParseBoolValue(val string, fallback bool) bool

ParseBoolValue parses the the boolean in val or, if there is an error, returns the specified default value

func ParseIntOrDuration added in v0.22.0

func ParseIntOrDuration(val string) (int, error)

ParseIntOrDurationValue interprets a string representing an int or duration and returns an int as the number of seconds. An error is returned if val can not be parsed as int or duration.

func ParseIntOrDurationValue

func ParseIntOrDurationValue(val string, fallback time.Duration) time.Duration

ParseIntOrDurationValue parses the the duration in val or, if there is an error, returns the specified default value

func ParseIntValue

func ParseIntValue(val string, fallback int) int

ParseIntValue parses the the int in val or, if there is an error, returns the specified default value

func ParseString

func ParseString(val string, fallback string) string

ParseString verifies the string in val is not empty. When empty, it returns the specified default value

Types

type APIAccessEvent added in v0.25.1

type APIAccessEvent struct {
	Actor         *Actor    `json:"actor,omitempty"`
	Path          string    `json:"path"`
	Method        string    `json:"method"`
	Actions       []string  `json:"actions"`
	ResponseCode  int       `json:"response_code"`
	CustomMessage string    `json:"custom_message,omitempty"`
	Namespace     string    `json:"namespace,omitempty"`
	Time          time.Time `json:"time"`
}

func (APIAccessEvent) EventType added in v0.25.1

func (e APIAccessEvent) EventType() string

type Actor added in v0.25.1

type Actor struct {
	// OIDC subject, a unique identifier of the user.
	Sub string `json:"sub"`
	// Full name of the subject, can be the name of a user of OpenFaaS component.
	Name string `json:"name,omitempty"`
	// OpenFaaS issuer
	Issuer string `json:"issuer,omitempty"`
	// Federated issuer
	FedIssuer string `json:"fed_issuer,omitempty"`
}

Actor is the user that triggered an event. Get from OIDC claims, we can add any of the default OIDC profile or email claim fields if desired.

type DeleteFunctionRequest added in v0.15.3

type DeleteFunctionRequest struct {
	FunctionName string `json:"functionName"`
	Namespace    string `json:"namespace,omitempty"`
}

DeleteFunctionRequest delete a deployed function

type Event added in v0.25.1

type Event interface {
	EventType() string
}

type FaaSConfig

type FaaSConfig struct {
	// TCPPort is the public port for the API.
	TCPPort *int
	// HTTP timeout for reading a request from clients.
	ReadTimeout time.Duration
	// HTTP timeout for writing a response from functions.
	WriteTimeout time.Duration
	// EnableHealth enables/disables the default health endpoint bound to "/healthz".
	//
	// Deprecated: basic auth is enabled automatcally by setting the HealthHandler in the FaaSHandlers
	// struct.  This value is not longer read or used.
	EnableHealth bool
	// EnableBasicAuth enforces basic auth on the API. If set, reads secrets from file-system
	// location specificed in `SecretMountPath`.
	EnableBasicAuth bool
	// SecretMountPath specifies where to read secrets from for embedded basic auth.
	SecretMountPath string
	// MaxIdleConns with a default value of 1024, can be used for tuning HTTP proxy performance.
	MaxIdleConns int
	// MaxIdleConnsPerHost with a default value of 1024, can be used for tuning HTTP proxy performance.
	MaxIdleConnsPerHost int
}

FaaSConfig set config for HTTP handlers

func (*FaaSConfig) GetMaxIdleConns

func (c *FaaSConfig) GetMaxIdleConns() int

GetMaxIdleConns is a helper to safely return the configured MaxIdleConns or the default value of 1024

func (*FaaSConfig) GetMaxIdleConnsPerHost

func (c *FaaSConfig) GetMaxIdleConnsPerHost() int

GetMaxIdleConns is a helper to safely return the configured MaxIdleConns or the default value which should then match the MaxIdleConns

func (*FaaSConfig) GetReadTimeout

func (c *FaaSConfig) GetReadTimeout() time.Duration

GetReadTimeout is a helper to safely return the configured ReadTimeout or the default value of 10s

type FaaSHandlers

type FaaSHandlers struct {
	// ListNamespace lists namespaces which are annotated for OpenFaaS
	ListNamespaces http.HandlerFunc

	// MutateNamespace mutates a namespace to be annotated for OpenFaaS
	// each namespace must contain an annotation of "openfaas=1"
	MutateNamespace http.HandlerFunc

	// FunctionProxy provides the function invocation proxy logic.  Use proxy.NewHandlerFunc to
	// use the standard OpenFaaS proxy implementation or provide completely custom proxy logic.
	FunctionProxy http.HandlerFunc

	// FunctionLister lists deployed functions within a namespace
	FunctionLister http.HandlerFunc

	// DeployFunction deploys a function which doesn't exist
	DeployFunction http.HandlerFunc

	// UpdateFunction updates an existing function
	UpdateFunction http.HandlerFunc

	DeleteFunction http.HandlerFunc

	FunctionStatus http.HandlerFunc

	ScaleFunction http.HandlerFunc

	Secrets http.HandlerFunc

	// Logs provides streaming json logs of functions
	Logs http.HandlerFunc

	// Health defines the default health endpoint bound to "/healthz
	// If the handler is not set, then the "/healthz" path will not be configured
	Health http.HandlerFunc

	Info http.HandlerFunc
}

FaaSHandlers provide handlers for OpenFaaS

type FunctionDeployment

type FunctionDeployment struct {

	// Service is the name of the function deployment
	Service string `json:"service"`

	// Image is a fully-qualified container image
	Image string `json:"image"`

	// Namespace for the function, if supported by the faas-provider
	Namespace string `json:"namespace,omitempty"`

	// EnvProcess overrides the fprocess environment variable and can be used
	// with the watchdog
	EnvProcess string `json:"envProcess,omitempty"`

	// EnvVars can be provided to set environment variables for the function runtime.
	EnvVars map[string]string `json:"envVars,omitempty"`

	// Constraints are specific to the faas-provider.
	Constraints []string `json:"constraints,omitempty"`

	// Secrets list of secrets to be made available to function
	Secrets []string `json:"secrets,omitempty"`

	// Labels are metadata for functions which may be used by the
	// faas-provider or the gateway
	Labels *map[string]string `json:"labels,omitempty"`

	// Annotations are metadata for functions which may be used by the
	// faas-provider or the gateway
	Annotations *map[string]string `json:"annotations,omitempty"`

	// Limits for function
	Limits *FunctionResources `json:"limits,omitempty"`

	// Requests of resources requested by function
	Requests *FunctionResources `json:"requests,omitempty"`

	// ReadOnlyRootFilesystem removes write-access from the root filesystem
	// mount-point.
	ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem,omitempty"`
}

FunctionDeployment represents a request to create or update a Function.

type FunctionNamespace added in v0.23.0

type FunctionNamespace struct {
	Name string `json:"name"`

	Annotations map[string]string `json:"annotations,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
}

FunctionNamespace is the namespace for a function

type FunctionResources

type FunctionResources struct {
	Memory string `json:"memory,omitempty"`
	CPU    string `json:"cpu,omitempty"`
}

FunctionResources Memory and CPU

type FunctionStatus

type FunctionStatus struct {

	// Name is the name of the function deployment
	Name string `json:"name"`

	// Image is a fully-qualified container image
	Image string `json:"image"`

	// Namespace for the function, if supported by the faas-provider
	Namespace string `json:"namespace,omitempty"`

	// EnvProcess overrides the fprocess environment variable and can be used
	// with the watchdog
	EnvProcess string `json:"envProcess,omitempty"`

	// EnvVars set environment variables for the function runtime
	EnvVars map[string]string `json:"envVars,omitempty"`

	// Constraints are specific to the faas-provider
	Constraints []string `json:"constraints,omitempty"`

	// Secrets list of secrets to be made available to function
	Secrets []string `json:"secrets,omitempty"`

	// Labels are metadata for functions which may be used by the
	// faas-provider or the gateway
	Labels *map[string]string `json:"labels,omitempty"`

	// Annotations are metadata for functions which may be used by the
	// faas-provider or the gateway
	Annotations *map[string]string `json:"annotations,omitempty"`

	// Limits for function
	Limits *FunctionResources `json:"limits,omitempty"`

	// Requests of resources requested by function
	Requests *FunctionResources `json:"requests,omitempty"`

	// ReadOnlyRootFilesystem removes write-access from the root filesystem
	// mount-point.
	ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem,omitempty"`

	// InvocationCount count of invocations
	InvocationCount float64 `json:"invocationCount,omitempty"`

	// Replicas desired within the cluster
	Replicas uint64 `json:"replicas,omitempty"`

	// AvailableReplicas is the count of replicas ready to receive
	// invocations as reported by the faas-provider
	AvailableReplicas uint64 `json:"availableReplicas,omitempty"`

	// CreatedAt is the time read back from the faas backend's
	// data store for when the function or its container was created.
	CreatedAt time.Time `json:"createdAt,omitempty"`

	// Usage represents CPU and RAM used by all of the
	// functions' replicas. Divide by AvailableReplicas for an
	// average value per replica.
	Usage *FunctionUsage `json:"usage,omitempty"`
}

FunctionStatus exported for system/functions endpoint

type FunctionUsage added in v0.18.9

type FunctionUsage struct {
	// CPU is the increase in CPU usage since the last measurement
	// equivalent to Kubernetes' concept of millicores.
	CPU float64 `json:"cpu,omitempty"`

	//TotalMemoryBytes is the total memory usage in bytes.
	TotalMemoryBytes float64 `json:"totalMemoryBytes,omitempty"`
}

FunctionUsage represents CPU and RAM used by all of the functions' replicas.

CPU is measured in seconds consumed since the last measurement RAM is measured in total bytes consumed

type FunctionUsageEvent added in v0.25.1

type FunctionUsageEvent struct {
	Namespace    string        `json:"namespace"`
	FunctionName string        `json:"function_name"`
	Started      time.Time     `json:"started"`
	Duration     time.Duration `json:"duration"`
	MemoryBytes  int64         `json:"memory_bytes"`
}

func (FunctionUsageEvent) EventType added in v0.25.1

func (e FunctionUsageEvent) EventType() string

type HasEnv

type HasEnv interface {
	Getenv(key string) string
}

HasEnv provides interface for os.Getenv

type OsEnv

type OsEnv struct {
}

OsEnv implements interface to wrap os.Getenv

func (OsEnv) Getenv

func (OsEnv) Getenv(key string) string

Getenv wraps os.Getenv

type ProviderInfo added in v0.16.2

type ProviderInfo struct {
	Name          string       `json:"provider"`
	Version       *VersionInfo `json:"version"`
	Orchestration string       `json:"orchestration"`
}

ProviderInfo provides information about the configured provider

type QueueRequest added in v0.18.6

type QueueRequest struct {
	// Header from HTTP request
	Header http.Header `json:"Header,omitempty"`

	// Host from HTTP request
	Host string `json:"Host,omitempty"`

	// Body from HTTP request to use for invocation
	Body []byte `json:"Body,omitempty"`

	// Method from HTTP request
	Method string `json:"Method"`

	// Path from HTTP request
	Path string `json:"Path,omitempty"`

	// QueryString from HTTP request
	QueryString string `json:"QueryString,omitempty"`

	// Function name to invoke
	Function string `json:"Function"`

	// QueueName to publish the request to, leave blank
	// for default.
	QueueName string `json:"QueueName,omitempty"`

	// Annotations defines a collection of meta-data that can be used by
	// the queue worker when processing the queued request.
	Annotations map[string]string `json:"Annotations,omitempty"`

	// Used by queue worker to submit a result
	CallbackURL *url.URL `json:"CallbackUrl,omitempty"`
}

Request for asynchronous processing

type ReadConfig

type ReadConfig struct {
}

ReadConfig constitutes config from env variables

func (ReadConfig) Read

func (ReadConfig) Read(hasEnv HasEnv) (*FaaSConfig, error)

Read fetches config from environmental variables.

type RequestQueuer added in v0.18.6

type RequestQueuer interface {
	Queue(req *QueueRequest) error
}

RequestQueuer can public a request to be executed asynchronously

type ScaleServiceRequest

type ScaleServiceRequest struct {
	ServiceName string `json:"serviceName"`
	Replicas    uint64 `json:"replicas"`
	Namespace   string `json:"namespace,omitempty"`
}

ScaleServiceRequest scales the service to the requested replica count.

type Secret

type Secret struct {
	// Name of the secret
	Name string `json:"name"`

	// Namespace if applicable for the secret
	Namespace string `json:"namespace,omitempty"`

	// Value is a string representing the string's value
	Value string `json:"value,omitempty"`

	// RawValue can be used to provide binary data when
	// Value is not set
	RawValue []byte `json:"rawValue,omitempty"`
}

Secret for underlying orchestrator

type VersionInfo added in v0.16.2

type VersionInfo struct {
	CommitMessage string `json:"commit_message,omitempty"`
	SHA           string `json:"sha"`
	Release       string `json:"release"`
}

VersionInfo provides the commit message, sha and release version number

Jump to

Keyboard shortcuts

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