Documentation ¶
Index ¶
- Constants
- type Context
- type DockerImageBuilder
- type FaaSDriver
- type FnRun
- type Function
- type FunctionError
- type FunctionExecution
- type FunctionResources
- type ImageBuilder
- type InputError
- type Message
- type Middleware
- type Runnable
- type Runner
- type Schema
- type Schemas
- type SecretInjector
- type ServiceInjector
- type Source
- type StackTracer
- type SystemError
- type Validator
Constants ¶
const ( LogsKey = "logs" EventKey = "event" ErrorKey = "error" HTTPContextKey = "httpContext" TimeoutKey = "timeout" )
Function context constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context map[string]interface{}
Context provides function context
func (Context) GetError ¶ added in v0.1.15
func (ctx Context) GetError() *v1.InvocationError
GetError returns the error from the context
func (Context) SetError ¶ added in v0.1.15
func (ctx Context) SetError(invocationError *v1.InvocationError)
SetError sets the error into the context
type DockerImageBuilder ¶ added in v0.1.13
type DockerImageBuilder struct { ImageRegistry string RegistryAuth string PushImages bool PullImages bool // contains filtered or unexported fields }
DockerImageBuilder builds function images
func NewDockerImageBuilder ¶ added in v0.1.13
func NewDockerImageBuilder(imageRegistry, registryAuth string, docker docker.CommonAPIClient) *DockerImageBuilder
NewDockerImageBuilder is the constructor for the DockerImageBuilder
func (*DockerImageBuilder) BuildImage ¶ added in v0.1.13
func (ib *DockerImageBuilder) BuildImage(ctx context.Context, f *Function, code []byte) (string, error)
BuildImage packages a function into a docker image. It also adds any FaaS specfic image layers
type FaaSDriver ¶
type FaaSDriver interface { // Create creates (or updates, if is already exists) the function in the FaaS implementation. // name is the name of the function. // exec defines the function implementation. Create(ctx context.Context, f *Function) error // Delete deletes the function in the FaaS implementation. // f is a reference to function defition. Delete(ctx context.Context, f *Function) error // GetRunnable returns a callable representation of a function. // e is a reference to FunctionExecution. GetRunnable(e *FunctionExecution) Runnable }
FaaSDriver manages Serverless functions and allows to create or delete function, as well as to retrieve runnable representation of the function.
type FnRun ¶
type FnRun struct { entitystore.BaseEntity FunctionName string `json:"functionName"` FunctionID string `json:"functionID"` FaasID string `json:"faasId"` Blocking bool `json:"blocking"` Input interface{} `json:"input,omitempty"` Output interface{} `json:"output,omitempty"` Secrets []string `json:"secrets,omitempty"` Services []string `json:"services,omitempty"` HTTPContext map[string]interface{} `json:"httpContext,omitempty"` Event *events.CloudEvent `json:"event,omitempty"` Logs *v1.Logs `json:"logs,omitempty"` Error *v1.InvocationError `json:"error,omitempty"` FinishedTime time.Time `json:"finishedTime,omitempty"` WaitChan chan struct{} `json:"-"` }
FnRun struct represents single function run
type Function ¶
type Function struct { entitystore.BaseEntity FaasID string `json:"faasId"` SourceURL string `json:"sourceURL"` Handler string `json:"handler"` ImageName string `json:"image"` ImageURL string `json:"imageURL"` FunctionImageURL string `json:"functionImageURL"` Schema *Schema `json:"schema,omitempty"` Secrets []string `json:"secrets,omitempty"` Services []string `json:"services,omitempty"` Timeout int64 `json:"timeout,omitempty"` }
Function struct represents function entity that is stored in entity store
type FunctionError ¶
type FunctionError interface {
AsFunctionErrorObject() interface{}
}
FunctionError represents error caused by the function
type FunctionExecution ¶
type FunctionExecution struct { Context Context OrganizationID string RunID string FunctionID string FaasID string Schemas *Schemas Secrets []string Services []string Cookie string }
FunctionExecution represents single instance of function execution
type FunctionResources ¶ added in v0.1.21
FunctionResources Memory and CPU
type ImageBuilder ¶ added in v0.1.13
type ImageBuilder interface { // BuildImage builds a function image and pushes it to the docker registry. // Returns image full name. BuildImage(ctx context.Context, f *Function, code []byte) (string, error) }
ImageBuilder builds a docker image for a serverless function.
type InputError ¶ added in v0.1.15
type InputError interface {
AsInputErrorObject() interface{}
}
InputError represents user/input error
type Message ¶ added in v0.1.13
type Message struct { Context Context `json:"context"` Payload interface{} `json:"payload"` }
Message contains context and payload for function invocations and events
type Middleware ¶
Middleware allows injecting extra steps for each function execution
type Runner ¶
type Runner interface {
Run(fn *FunctionExecution, in interface{}) (interface{}, error)
}
Runner knows how to execute a function
type Schema ¶
type Schema struct { In *spec.Schema `json:"in,omitempty"` Out *spec.Schema `json:"out,omitempty"` }
Schema struct stores input and output validation schemas
type Schemas ¶
type Schemas struct { // SchemaIn is the function input validation schema data structure. Can be nil. SchemaIn interface{} // SchemaOut is the function output validation schema data structure. Can be nil. SchemaOut interface{} }
Schemas represent function validation schemas
type SecretInjector ¶
type SecretInjector interface {
GetMiddleware(organizationID string, secrets []string, cookie string) Middleware
}
SecretInjector injects secrets into function execution
type ServiceInjector ¶ added in v0.1.13
type ServiceInjector interface {
GetMiddleware(organizationID string, services []string, cookie string) Middleware
}
ServiceInjector injects service bindings into function execution
type Source ¶ added in v0.1.22
type Source struct { entitystore.BaseEntity Code []byte `json:"code"` }
Source struct represents function source code that is stored in entity store
type StackTracer ¶ added in v0.1.15
type StackTracer interface {
StackTrace() errors.StackTrace
}
StackTracer is part of the errors pkg public API and returns the error stacktrace
type SystemError ¶ added in v0.1.15
type SystemError interface {
AsSystemErrorObject() interface{}
}
SystemError represents error in the Dispatch infrastructure
type Validator ¶
type Validator interface {
GetMiddleware(schemas *Schemas) Middleware
}
Validator validates function input/output