function

package
v0.0.0-...-089673d Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 5 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProvider

func RegisterProvider(providerType ProviderType, loader ProviderLoader)

RegisterProvider registers provider loader by provider type.

Types

type ErrFunctionAccessDenied

type ErrFunctionAccessDenied struct {
	Original error
}

ErrFunctionAccessDenied occurs when Event Gateway don't have access to call a function.

func (ErrFunctionAccessDenied) Error

func (e ErrFunctionAccessDenied) Error() string

type ErrFunctionAlreadyRegistered

type ErrFunctionAlreadyRegistered struct {
	ID ID
}

ErrFunctionAlreadyRegistered occurs when function with specified name is already registered.

func (ErrFunctionAlreadyRegistered) Error

type ErrFunctionCallFailed

type ErrFunctionCallFailed struct {
	Original error
}

ErrFunctionCallFailed occurs when function call failed.

func (ErrFunctionCallFailed) Error

func (e ErrFunctionCallFailed) Error() string

type ErrFunctionError

type ErrFunctionError struct {
	Original error
}

ErrFunctionError occurs when function call failed because of function error.

func (ErrFunctionError) Error

func (e ErrFunctionError) Error() string

type ErrFunctionHasSubscriptions

type ErrFunctionHasSubscriptions struct{}

ErrFunctionHasSubscriptions occurs when function with subscription is being deleted.

func (ErrFunctionHasSubscriptions) Error

type ErrFunctionIsAuthorizer

type ErrFunctionIsAuthorizer struct {
	ID        ID
	EventType string
}

ErrFunctionIsAuthorizer occurs when function cannot be deleted because is used as authorizer.

func (ErrFunctionIsAuthorizer) Error

func (e ErrFunctionIsAuthorizer) Error() string

type ErrFunctionNotFound

type ErrFunctionNotFound struct {
	ID ID
}

ErrFunctionNotFound occurs when function couldn't been found in the discovery.

func (ErrFunctionNotFound) Error

func (e ErrFunctionNotFound) Error() string

type ErrFunctionProviderError

type ErrFunctionProviderError struct {
	Original error
}

ErrFunctionProviderError occurs when function call failed because of provider error.

func (ErrFunctionProviderError) Error

func (e ErrFunctionProviderError) Error() string

type ErrFunctionValidation

type ErrFunctionValidation struct {
	Message string
}

ErrFunctionValidation occurs when function payload doesn't validate.

func (ErrFunctionValidation) Error

func (e ErrFunctionValidation) Error() string

type Function

type Function struct {
	Space          string           `json:"space" validate:"required,min=3,space"`
	ID             ID               `json:"functionId" validate:"required,functionid"`
	ProviderType   ProviderType     `json:"type"`
	ProviderConfig *json.RawMessage `json:"provider"`
	Provider       Provider         `json:"-" validate:"-"`

	Metadata metadata.Metadata `json:"metadata,omitempty"`
}

Function represents a function deployed on one of the supported providers.

func (*Function) Call

func (f *Function) Call(payload []byte) ([]byte, error)

Call tries to send a payload to a target function

func (*Function) MarshalJSON

func (f *Function) MarshalJSON() ([]byte, error)

MarshalJSON marshals provides as config and returns JSON representation of the function.

func (Function) MarshalLogObject

func (f Function) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject is a part of zapcore.ObjectMarshaler interface

func (*Function) UnmarshalJSON

func (f *Function) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals function JSON, detects provider type and loads the provider.

type Functions

type Functions []*Function

Functions is an array of functions.

type ID

type ID string

ID uniquely identifies a function.

type Provider

type Provider interface {
	Call(payload []byte) ([]byte, error)
	MarshalLogObject(enc zapcore.ObjectEncoder) error
}

Provider is an interface that function provider has to implement.

type ProviderLoader

type ProviderLoader interface {
	Load(config []byte) (Provider, error)
}

ProviderLoader returns Provider instance based on JSON config blob.

type ProviderType

type ProviderType string

ProviderType represents function provier type.

type Service

type Service interface {
	GetFunction(space string, id ID) (*Function, error)
	ListFunctions(space string, filters ...metadata.Filter) (Functions, error)
	CreateFunction(fn *Function) (*Function, error)
	UpdateFunction(fn *Function) (*Function, error)
	DeleteFunction(space string, id ID) error
}

Service represents service for managing functions.

Jump to

Keyboard shortcuts

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