Documentation ¶
Index ¶
- Constants
- type Context
- type DockerImageBuilder
- type Exec
- type FaaSDriver
- type FnRun
- type Function
- type FunctionError
- type FunctionExecution
- type ImageBuilder
- type Message
- type Middleware
- type Runnable
- type Runner
- type Schema
- type Schemas
- type SecretInjector
- type ServiceInjector
- type UserError
- type Validator
Constants ¶
const ( LogsKey = "logs" EventKey = "event" HTTPContextKey = "httpContext" )
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
type DockerImageBuilder ¶ added in v0.1.13
type DockerImageBuilder struct {
// contains filtered or unexported fields
}
DockerImageBuilder builds function images
func NewDockerImageBuilder ¶ added in v0.1.13
func NewDockerImageBuilder(imageRegistry, registryAuth string, docker *docker.Client) *DockerImageBuilder
NewDockerImageBuilder is the constructor for the DockerImageBuilder
func (*DockerImageBuilder) BuildImage ¶ added in v0.1.13
func (ib *DockerImageBuilder) BuildImage(faas, fnID string, exec *Exec) (string, error)
BuildImage packages a function into a docker image. It also adds any FaaS specfic image layers
type Exec ¶
type Exec struct { // Code is the function code, either as readable text or base64 encoded (for .zip and .jar archives) Code string // Main is the function's entry point (aka main function), by default "main" Main string // Image is the function's docker image Image string // Name is the function's name Name string }
Exec includes data required to execute a function
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(f *Function, exec *Exec) error // Delete deletes the function in the FaaS implementation. // f is a reference to function defition. Delete(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"` 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"` Code string `json:"code"` Main string `json:"main"` ImageName string `json:"image"` Schema *Schema `json:"schema,omitempty"` Secrets []string `json:"secrets,omitempty"` Services []string `json:"services,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 RunID string FunctionID string FaasID string Schemas *Schemas Secrets []string Services []string Cookie string }
FunctionExecution represents single instance of function execution
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(faas, fnID string, e *Exec) (string, error) }
ImageBuilder builds a docker image for a serverless function.
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(secrets []string, cookie string) Middleware
}
SecretInjector injects secrets into function execution
type ServiceInjector ¶ added in v0.1.13
type ServiceInjector interface {
GetMiddleware(services []string, cookie string) Middleware
}
ServiceInjector injects service bindings into function execution
type UserError ¶
type UserError interface {
AsUserErrorObject() interface{}
}
UserError represents user error
type Validator ¶
type Validator interface {
GetMiddleware(schemas *Schemas) Middleware
}
Validator validates function input/output