functions

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: Apache-2.0 Imports: 23 Imported by: 41

Documentation

Index

Constants

View Source
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) AddLogs added in v0.1.13

func (ctx Context) AddLogs(logs v1.Logs)

AddLogs adds the logs into the context

func (Context) GetError added in v0.1.15

func (ctx Context) GetError() *v1.InvocationError

GetError returns the error from the context

func (Context) Logs

func (ctx Context) Logs() v1.Logs

Logs returns the logs as a list of strings

func (Context) ReadLogs added in v0.1.13

func (ctx Context) ReadLogs(stderrReader io.Reader, stdoutReader io.Reader)

ReadLogs reads the logs into 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

func (*FnRun) Done

func (r *FnRun) Done()

Done reports completion of function execution

func (*FnRun) Wait

func (r *FnRun) Wait()

Wait waits for function execution to finish

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

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

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

type Middleware func(f Runnable) Runnable

Middleware allows injecting extra steps for each function execution

type Runnable

type Runnable func(ctx Context, in interface{}) (interface{}, error)

Runnable is a runnable representation of a function

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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