models

package
v0.0.0-...-3e3bf6f Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeNone ...
	TypeNone = ""
	// TypeSync ...
	TypeSync = "sync"
	// TypeDetached is used for calls which return an ack to the caller as soon as the call starts
	TypeDetached = "detached"
)
View Source
const (
	MinMilliCPUs = 0       // 0 is unlimited
	MaxMilliCPUs = 1024000 // 1024 CPUs
)
View Source
const (
	// MaxLengthAppName is the max length for an app name
	MaxLengthAppName = 255
	// MaxLengthFnName is the max length for an fn name
	MaxLengthFnName = 255
	// MaxLengthTriggerName is the max length for a trigger name
	MaxLengthTriggerName = 255
)
View Source
const FnInvokeEndpointAnnotation = "fnproject.io/fn/invokeEndpoint"

FnInvokeEndpointAnnotation is the annotation that exposes the fn invoke endpoint For want of a better place to put this it's here

View Source
const TriggerHTTPEndpointAnnotation = "fnproject.io/trigger/httpEndpoint"

TriggerHTTPEndpointAnnotation is the annotation that exposes the HTTP trigger endpoint For want of a better place to put this it's here

View Source
const TriggerTypeHTTP = "http"

TriggerTypeHTTP represents an HTTP trigger

Variables

View Source
var (
	ErrAppsMissingID = err{
						// contains filtered or unexported fields
	}
	ErrAppIDProvided = err{
						// contains filtered or unexported fields
	}
	ErrAppsIDMismatch = err{
						// contains filtered or unexported fields
	}
	ErrAppsMissingName = err{
						// contains filtered or unexported fields
	}
	ErrAppsTooLongName = err{
						// contains filtered or unexported fields
	}
	ErrAppsInvalidName = err{
						// contains filtered or unexported fields
	}
	ErrAppsAlreadyExists = err{
							// contains filtered or unexported fields
	}
	ErrAppsMissingNew = err{
						// contains filtered or unexported fields
	}
	ErrAppsNameImmutable = err{
							// contains filtered or unexported fields
	}

	ErrAppsNotFound = err{
					// contains filtered or unexported fields
	}
)
View Source
var (
	ErrMethodNotAllowed = err{
						// contains filtered or unexported fields
	}

	ErrInvalidJSON = err{
					// contains filtered or unexported fields
	}
	ErrClientCancel = err{
					// contains filtered or unexported fields
	}
	ErrCallTimeoutServerBusy = err{
								// contains filtered or unexported fields
	}
	ErrUnsupportedMediaType = err{
							// contains filtered or unexported fields
	}

	ErrMissingID = err{
					// contains filtered or unexported fields
	}

	ErrMissingAppID = err{
					// contains filtered or unexported fields
	}
	ErrMissingFnID = err{
					// contains filtered or unexported fields
	}
	ErrMissingName = err{
					// contains filtered or unexported fields
	}

	ErrCreatedAtProvided = err{
							// contains filtered or unexported fields
	}
	ErrUpdatedAtProvided = err{
							// contains filtered or unexported fields
	}

	ErrDatastoreEmptyApp = err{
							// contains filtered or unexported fields
	}
	ErrDatastoreEmptyCallID = err{
							// contains filtered or unexported fields
	}
	ErrDatastoreEmptyFn = err{
						// contains filtered or unexported fields
	}
	ErrDatastoreEmptyFnID = err{
							// contains filtered or unexported fields
	}
	ErrInvalidPayload = err{
						// contains filtered or unexported fields
	}
	ErrFoundDynamicURL = err{
						// contains filtered or unexported fields
	}
	ErrPathMalformed = err{
						// contains filtered or unexported fields
	}
	ErrInvalidToTime = err{
						// contains filtered or unexported fields
	}
	ErrInvalidFromTime = err{
						// contains filtered or unexported fields
	}
	ErrInvalidMemory = err{
						// contains filtered or unexported fields
	}
	ErrCallResourceTooBig = err{
							// contains filtered or unexported fields
	}
	ErrCallNotFound = err{
					// contains filtered or unexported fields
	}
	ErrInvalidCPUs = err{
					// contains filtered or unexported fields
	}
	ErrCallLogNotFound = err{
						// contains filtered or unexported fields
	}
	ErrPathNotFound = err{
					// contains filtered or unexported fields
	}
	ErrInvalidAnnotationKey = err{
							// contains filtered or unexported fields
	}
	ErrInvalidAnnotationKeyLength = err{
									// contains filtered or unexported fields
	}
	ErrInvalidAnnotationValue = err{
								// contains filtered or unexported fields
	}
	ErrInvalidAnnotationValueLength = err{
									// contains filtered or unexported fields
	}
	ErrTooManyAnnotationKeys = err{
								// contains filtered or unexported fields
	}
	ErrTooManyRequests = err{
						// contains filtered or unexported fields
	}
	ErrAsyncUnsupported = err{
						// contains filtered or unexported fields
	}

	ErrDetachUnsupported = err{
							// contains filtered or unexported fields
	}

	ErrCallHandlerNotFound = err{
							// contains filtered or unexported fields
	}
	ErrServiceReservationFailure = err{
									// contains filtered or unexported fields
	}

	ErrDockerPullTimeout = ferr{
							// contains filtered or unexported fields
	}
	ErrFunctionResponseTooBig = ferr{
								// contains filtered or unexported fields
	}
	ErrFunctionResponseHdrTooBig = ferr{
									// contains filtered or unexported fields
	}
	ErrFunctionResponse = ferr{
						// contains filtered or unexported fields
	}
	ErrFunctionFailed = ferr{
						// contains filtered or unexported fields
	}
	ErrFunctionInvalidResponse = ferr{
								// contains filtered or unexported fields
	}
	ErrFunctionPrematureWrite = ferr{
								// contains filtered or unexported fields
	}
	ErrFunctionWriteRequest = ferr{
							// contains filtered or unexported fields
	}
	ErrRequestContentTooBig = ferr{
							// contains filtered or unexported fields
	}
	ErrCallTimeout = ferr{
					// contains filtered or unexported fields
	}
	ErrContainerInitFail = ferr{
							// contains filtered or unexported fields
	}
	ErrContainerInitTimeout = ferr{
							// contains filtered or unexported fields
	}

	ErrSyslogUnavailable = ferr{
							// contains filtered or unexported fields
	}
	ErrRequestLimitExceeded = ferr{
							// contains filtered or unexported fields
	}
)
View Source
var (
	MaxMemory      uint64 = 8 * 1024 // 8GB
	MaxTimeout     int32  = 300      // 5m
	MaxIdleTimeout int32  = 3600     // 1h

	DefaultTimeout     int32  = 30  // seconds
	DefaultIdleTimeout int32  = 30  // seconds
	DefaultMemory      uint64 = 128 // MB

	ErrFnsIDMismatch = err{
						// contains filtered or unexported fields
	}
	ErrFnsIDProvided = err{
						// contains filtered or unexported fields
	}
	ErrFnsMissingID = err{
					// contains filtered or unexported fields
	}
	ErrFnsMissingName = err{
						// contains filtered or unexported fields
	}
	ErrFnsInvalidName = err{
						// contains filtered or unexported fields
	}
	ErrFnsTooLongName = err{
						// contains filtered or unexported fields
	}
	ErrFnsMissingAppID = err{
						// contains filtered or unexported fields
	}
	ErrFnsMissingImage = err{
						// contains filtered or unexported fields
	}
	ErrFnsInvalidImage = err{
						// contains filtered or unexported fields
	}
	ErrFnsInvalidTimeout = err{
							// contains filtered or unexported fields
	}
	ErrFnsInvalidIdleTimeout = err{
								// contains filtered or unexported fields
	}
	ErrFnsNotFound = err{
					// contains filtered or unexported fields
	}
	ErrFnsExists = err{
					// contains filtered or unexported fields
	}
)
View Source
var (
	//ErrTriggerIDProvided indicates that a trigger ID was specified when it shouldn't have been
	ErrTriggerIDProvided = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerIDMismatch indicates an ID was provided that did not match the ID of the corresponding operation/call
	ErrTriggerIDMismatch = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerMissingName - name not specified on a trigger object
	ErrTriggerMissingName = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerTooLongName - name exceeds maximum permitted name
	ErrTriggerTooLongName = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerInvalidName - name does not comply with naming spec
	ErrTriggerInvalidName = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerMissingAppID - no API id specified on trigger creation
	ErrTriggerMissingAppID = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerMissingFnID - no FNID specified on trigger creation
	ErrTriggerMissingFnID = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerFnIDNotSameApp - specified Fn does not belong to the same app as the provided AppID
	ErrTriggerFnIDNotSameApp = err{
								// contains filtered or unexported fields
	}
	//ErrTriggerTypeUnknown - unsupported trigger type
	ErrTriggerTypeUnknown = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerMissingSource - no source spceified for trigger
	ErrTriggerMissingSource = err{
							// contains filtered or unexported fields
	}
	//ErrTriggerMissingSourcePrefix - source does not have a / prefix
	ErrTriggerMissingSourcePrefix = err{
									// contains filtered or unexported fields
	}
	//ErrTriggerNotFound - trigger not found
	ErrTriggerNotFound = err{
						// contains filtered or unexported fields
	}
	//ErrTriggerExists - a trigger with the specified name already exists
	ErrTriggerExists = err{
						// contains filtered or unexported fields
	}
	//ErrTriggerSourceExists - another trigger on the same app has the same source and type
	ErrTriggerSourceExists = err{
							// contains filtered or unexported fields
	}
)

Functions

func GetAPIErrorCode

func GetAPIErrorCode(e error) int

GetAPIErrorCode returns 0 if an error is not an APIError, or the result of the Code() method from an APIError

func IsAPIError

func IsAPIError(e error) bool

IsAPIError returns whether err implements APIError

func IsFuncError

func IsFuncError(err error) bool

IsFuncError checks if err is of type FuncError

func NewFuncError

func NewFuncError(err APIError) error

NewFuncError returns a FuncError

func ValidTriggerType

func ValidTriggerType(a string) bool

ValidTriggerType checks that a given trigger type is valid on this service

func ValidTriggerTypes

func ValidTriggerTypes() []string

ValidTriggerTypes lists the supported trigger types in this service

Types

type APIError

type APIError interface {
	Code() int
	error
}

APIError any error that implements this interface will return an API response with the provided status code and error message body

func NewAPIError

func NewAPIError(code int, e error) APIError

NewAPIError returns an APIError given a code and error

type APIErrorWrapper

type APIErrorWrapper interface {
	APIError
	RootError() error
}

APIErrorWrapper wraps an error with an APIError such that the APIError governs the HTTP response but the root error remains accessible.

func NewAPIErrorWrapper

func NewAPIErrorWrapper(apiErr APIError, rootErr error) APIErrorWrapper

type Annotations

type Annotations map[string]*annotationValue

Annotations encapsulates key-value metadata associated with resource. The structure is immutable via its public API and nil-safe for its contract permissive nilability is here to simplify updates and reduce the need for nil handling in extensions - annotations should be updated by over-writing the original object:

target.Annotations  = target.Annotations.With("fooKey",1)

old MD remains empty Annotations is lenable

func EmptyAnnotations

func EmptyAnnotations() Annotations

func (Annotations) Equals

func (m Annotations) Equals(other Annotations) bool

Equals is defined based on un-ordered k/v comparison at of the annotation keys and (compacted) values of annotations, JSON object-value equality for values is property-order dependent

func (Annotations) Get

func (m Annotations) Get(key string) ([]byte, bool)

Get returns a raw JSON value of a annotation key

func (Annotations) GetString

func (m Annotations) GetString(key string) (string, error)

GetString returns a string value if the annotation value is a string, otherwise an error

func (Annotations) MergeChange

func (m Annotations) MergeChange(newVs Annotations) Annotations

MergeChange merges a delta (possibly including deletes) with an existing annotations object and returns a new (copy) annotations object or an error. This assumes that both old and new annotations objects contain only valid keys and only newVs may contain deletes

func (*Annotations) Scan

func (m *Annotations) Scan(value interface{}) error

Scan implements sql.Scanner

func (Annotations) Subset

func (m Annotations) Subset(other Annotations) bool

func (Annotations) Validate

func (m Annotations) Validate() APIError

Validate validates a final annotations object prior to store, This will reject partial/patch changes with empty values (containing deletes)

func (Annotations) Value

func (m Annotations) Value() (driver.Value, error)

Value implements sql.Valuer, returning a string

func (Annotations) With

func (m Annotations) With(key string, data interface{}) (Annotations, error)

With Creates a new annotations object containing the specified value - this does not perform size checks on the total number of keys this validates the correctness of the key and value. this returns a new the annotations object with the key set.

func (Annotations) Without

func (m Annotations) Without(key string) Annotations

Without returns a new annotations object with a value excluded

type App

type App struct {
	ID          string          `json:"id" db:"id"`
	Name        string          `json:"name" db:"name"`
	Config      Config          `json:"config,omitempty" db:"config"`
	Annotations Annotations     `json:"annotations,omitempty" db:"annotations"`
	SyslogURL   *string         `json:"syslog_url,omitempty" db:"syslog_url"`
	CreatedAt   common.DateTime `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt   common.DateTime `json:"updated_at,omitempty" db:"updated_at"`
}

func (*App) Clone

func (a *App) Clone() *App

func (*App) Equals

func (a1 *App) Equals(a2 *App) bool

func (*App) EqualsWithAnnotationSubset

func (a1 *App) EqualsWithAnnotationSubset(a2 *App) bool

func (*App) Update

func (a *App) Update(patch *App)

Update adds entries from patch to a.Config and a.Annotations, and removes entries with empty values.

func (*App) Validate

func (a *App) Validate() error

func (*App) ValidateName

func (a *App) ValidateName() error

type AppFilter

type AppFilter struct {
	Name    string
	PerPage int
	Cursor  string
}

AppFilter is the filter used for querying apps

type AppList

type AppList struct {
	NextCursor string `json:"next_cursor,omitempty"`
	Items      []*App `json:"items"`
}

type AppWrapper

type AppWrapper struct {
	App *App `json:"app"`
}

func (*AppWrapper) Validate

func (m *AppWrapper) Validate() error

type Call

type Call struct {
	// Unique identifier representing a specific call.
	ID string `json:"id" db:"id"`

	// NOTE: this is stale, retries are not implemented atm, but this is nice, so leaving
	//  States and valid transitions.
	//
	//                  +---------+
	//        +---------> delayed <----------------+
	//                  +----+----+                |
	//                       |                     |
	//                       |                     |
	//                  +----v----+                |
	//        +---------> queued  <----------------+
	//                  +----+----+                *
	//                       |                     *
	//                       |               retry * creates new call
	//                  +----v----+                *
	//                  | running |                *
	//                  +--+-+-+--+                |
	//           +---------|-|-|-----+-------------+
	//       +---|---------+ | +-----|---------+   |
	//       |   |           |       |         |   |
	// +-----v---^-+      +--v-------^+     +--v---^-+
	// | success   |      | cancelled |     |  error |
	// +-----------+      +-----------+     +--------+
	//
	// * delayed - has a delay.
	// * queued - Ready to be consumed when it's turn comes.
	// * running - Currently consumed by a runner which will attempt to process it.
	// * success - (or complete? success/error is common javascript terminology)
	// * error - Something went wrong. In this case more information can be obtained
	//   by inspecting the "reason" field.
	//   - timeout
	//   - killed - forcibly killed by worker due to resource restrictions or access
	//     violations.
	//   - bad_exit - exited with non-zero status due to program termination/crash.
	// * cancelled - cancelled via API. More information in the reason field.
	//   - client_request - Request was cancelled by a client.
	Status string `json:"status" db:"status"`

	// Name of Docker image to use.
	Image string `json:"image,omitempty" db:"-"`

	// Number of seconds to wait before queueing the call for consumption for the
	// first time. Must be a positive integer. Calls with a delay start in state
	// "delayed" and transition to "running" after delay seconds.
	Delay int32 `json:"delay,omitempty" db:"-"`

	// Type indicates a call's type
	Type string `json:"type,omitempty" db:"-"`

	// Payload for the call. This is only used by async calls, to store their input.
	// TODO should we copy it into here too for debugging sync?
	Payload string `json:"payload,omitempty" db:"-"`

	// Full request url that spawned this invocation.
	URL string `json:"url,omitempty" db:"-"`

	// Method of the http request used to make this call.
	Method string `json:"method,omitempty" db:"-"`

	// Maximum runtime in seconds.
	Timeout int32 `json:"timeout,omitempty" db:"-"`

	// Hot function idle timeout in seconds before termination.
	IdleTimeout int32 `json:"idle_timeout,omitempty" db:"-"`

	// Tmpfs size in megabytes.
	TmpFsSize uint32 `json:"tmpfs_size,omitempty" db:"-"`

	// Memory is the amount of RAM this call is allocated.
	Memory uint64 `json:"memory,omitempty" db:"-"`

	// CPU as in MilliCPUs where each CPU core is split into 1000 units, specified either
	// *) milliCPUs as "100m" which is 1/10 of a CPU or
	// *) as floating point number "0.1" which is 1/10 of a CPU
	CPUs MilliCPUs `json:"cpus,omitempty" db:"-"`

	// Config is the set of configuration variables for the call
	Config Config `json:"config,omitempty" db:"-"`

	// Annotations is the set of annotations for the app/fn of the call.
	Annotations Annotations `json:"annotations,omitempty" db:"-"`

	// Headers are headers from the request that created this call
	Headers http.Header `json:"headers,omitempty" db:"-"`

	// SyslogURL is a syslog URL to send all logs to.
	SyslogURL string `json:"syslog_url,omitempty" db:"-"`

	// Time when call completed, whether it was successful or failed. Always in UTC.
	CompletedAt common.DateTime `json:"completed_at,omitempty" db:"completed_at"`

	// Time when call was submitted. Always in UTC.
	CreatedAt common.DateTime `json:"created_at,omitempty" db:"created_at"`

	// Time when call started execution. Always in UTC.
	StartedAt common.DateTime `json:"started_at,omitempty" db:"started_at"`

	// Duration that user code was running for, in nanoseconds.
	ExecutionDuration time.Duration `json:"execution_duration,omitempty" db:"execution_duration"`

	// Stats is a list of metrics from this call's execution, possibly empty.
	Stats stats.Stats `json:"stats,omitempty" db:"stats"`

	// Error is the reason why the call failed, it is only non-empty if
	// status is equal to "error".
	Error string `json:"error,omitempty" db:"error"`

	// App this call belongs to.
	AppID string `json:"app_id" db:"app_id"`

	// Name of the app.
	AppName string `json:"app_name" db:"app_name"`

	// Trigger this call belongs to.
	TriggerID string `json:"trigger_id" db:"trigger_id"`

	// Fn this call belongs to.
	FnID string `json:"fn_id" db:"fn_id"`
}

Call is a representation of a specific invocation of a fn.

type CallFilter

type CallFilter struct {
	FnID     string //match
	FromTime common.DateTime
	ToTime   common.DateTime
	Cursor   string
	PerPage  int
}

type CallList

type CallList struct {
	NextCursor string  `json:"next_cursor,omitempty"`
	Items      []*Call `json:"items"`
}

type Config

type Config map[string]string

func (Config) Equals

func (c1 Config) Equals(c2 Config) bool

func (*Config) Scan

func (c *Config) Scan(value interface{}) error

Scan implements sql.Scanner

func (*Config) Validate

func (c *Config) Validate() error

func (Config) Value

func (c Config) Value() (driver.Value, error)

Value implements sql.Valuer, returning a string

type Datastore

type Datastore interface {
	// GetAppByID gets an App by ID.
	// Returns ErrAppsNotFound if no app is found.
	GetAppByID(ctx context.Context, appID string) (*App, error)

	// GetAppID gets an app ID by app name, ensures if app exists.
	// Returns ErrDatastoreEmptyAppName for empty appName.
	// Returns ErrAppsNotFound if no app is found.
	GetAppID(ctx context.Context, appName string) (string, error)

	// GetApps gets a slice of Apps, optionally filtered by name, and a cursor.
	// Missing filter or empty name will match all Apps.
	GetApps(ctx context.Context, filter *AppFilter) (*AppList, error)

	// InsertApp inserts an App. Returns ErrDatastoreEmptyApp when app is nil, and
	// ErrDatastoreEmptyAppName when app.Name is empty.
	// Returns ErrAppsAlreadyExists if an App by the same name already exists.
	InsertApp(ctx context.Context, app *App) (*App, error)

	// UpdateApp updates an App's Config. Returns ErrDatastoreEmptyApp when app is nil, and
	// ErrDatastoreEmptyAppName when app.Name is empty.
	// Returns ErrAppsNotFound if an App is not found.
	UpdateApp(ctx context.Context, app *App) (*App, error)

	// RemoveApp removes the App named appName. Returns ErrDatastoreEmptyAppName if appName is empty.
	// Returns ErrAppsNotFound if an App is not found.
	RemoveApp(ctx context.Context, appID string) error

	// InsertFn inserts a new function if one does not exist, applying any defaults necessary,
	InsertFn(ctx context.Context, fn *Fn) (*Fn, error)

	// UpdateFn  updates a function that exists under the same id.
	// ErrMissingName is func.Name is empty.
	UpdateFn(ctx context.Context, fn *Fn) (*Fn, error)

	// GetFns returns a list of funcs, and a cursor, applying any additional filters provided.
	GetFns(ctx context.Context, filter *FnFilter) (*FnList, error)

	// GetFnByID returns a function by ID. Returns ErrDatastoreEmptyFnID if fnID is empty.
	// Returns ErrFnsNotFound if a fn is not found.
	GetFnByID(ctx context.Context, fnID string) (*Fn, error)

	// RemoveFn removes a function. Returns ErrDatastoreEmptyFnID if fnID is empty.
	// Returns ErrFnsNotFound if a func is not found.
	RemoveFn(ctx context.Context, fnID string) error

	// InsertTrigger inserts a trigger. Returns ErrDatastoreEmptyTrigger when trigger is nil, and specific errors for each field
	// Returns ErrTriggerAlreadyExists if the exact apiID, fnID, source, type combination already exists
	InsertTrigger(ctx context.Context, trigger *Trigger) (*Trigger, error)

	//UpdateTrigger updates a trigger object in the data store
	UpdateTrigger(ctx context.Context, trigger *Trigger) (*Trigger, error)

	// RemoveTrigger Removes a Trigger. Returns field specific errors if they are empty.
	// Returns nil if successful
	RemoveTrigger(ctx context.Context, triggerID string) error

	// GetTriggerByID gets a trigger by it's id.
	// Returns ErrTriggerNotFound when no matching trigger is found
	GetTriggerByID(ctx context.Context, triggerID string) (*Trigger, error)

	// GetTriggers gets a list of triggers that match the specified filter
	// Return ErrDatastoreEmptyAppId if no AppID set in the filter
	GetTriggers(ctx context.Context, filter *TriggerFilter) (*TriggerList, error)

	// GetTriggerBySource loads a trigger by type and source ID - this is only needed when the data store is also used for agent read access
	GetTriggerBySource(ctx context.Context, appId string, triggerType, source string) (*Trigger, error)

	// Closer implements io.Closer to shut down
	io.Closer
}

type ErrInvalidSyslog

type ErrInvalidSyslog string

func (ErrInvalidSyslog) Code

func (e ErrInvalidSyslog) Code() int

func (ErrInvalidSyslog) Error

func (e ErrInvalidSyslog) Error() string

type Error

type Error struct {
	Message string `json:"message,omitempty"`
	Fields  string `json:"fields,omitempty"`
}

func (*Error) Validate

func (m *Error) Validate() error

Validate validates this error body

type ErrorWrapper

type ErrorWrapper struct {
	Error *Error `json:"error,omitempty"`
}

ErrorWrapper uniform error output (v1) only

func (*ErrorWrapper) Validate

func (m *ErrorWrapper) Validate() error

type Fn

type Fn struct {
	// ID is the generated resource id.
	ID string `json:"id" db:"id"`
	// Name is a user provided name for this fn.
	Name string `json:"name" db:"name"`
	// AppID is the name of the app this fn belongs to.
	AppID string `json:"app_id" db:"app_id"`
	// Image is the fully qualified container registry address to execute.
	// examples: hub.docker.io/me/myfunc, me/myfunc, me/func:0.0.1
	Image string `json:"image" db:"image"`
	// ResourceConfig specifies resource constraints.
	ResourceConfig // embed (TODO or not?)
	// Config is the configuration passed to a function at execution time.
	Config Config `json:"config" db:"config"`
	// Annotations allow additional configuration of a function, these are not passed to the function.
	Annotations Annotations `json:"annotations,omitempty" db:"annotations"`
	// CreatedAt is the UTC timestamp when this function was created.
	CreatedAt common.DateTime `json:"created_at,omitempty" db:"created_at"`
	// UpdatedAt is the UTC timestamp of the last time this func was modified.
	UpdatedAt common.DateTime `json:"updated_at,omitempty" db:"updated_at"`
}

Fn contains information about a function configuration.

func (*Fn) Clone

func (f *Fn) Clone() *Fn

func (*Fn) Equals

func (f1 *Fn) Equals(f2 *Fn) bool

func (*Fn) EqualsWithAnnotationSubset

func (f1 *Fn) EqualsWithAnnotationSubset(f2 *Fn) bool

func (*Fn) SetDefaults

func (f *Fn) SetDefaults()

SetCreated sets zeroed field to defaults.

func (*Fn) Update

func (f *Fn) Update(patch *Fn)

Update updates fields in f with non-zero field values from new, and sets updated_at if any of the fields change. 0-length slice Header values, and empty-string Config values trigger removal of map entry.

func (*Fn) Validate

func (f *Fn) Validate() error

Validate validates all field values, returning the first error, if any.

func (*Fn) ValidateName

func (f *Fn) ValidateName() error

type FnFilter

type FnFilter struct {
	AppID   string // this is exact match
	Name    string //exact match
	Cursor  string
	PerPage int
}

type FnList

type FnList struct {
	NextCursor string `json:"next_cursor,omitempty"`
	Items      []*Fn  `json:"items"`
}

type FuncError

type FuncError interface {
	APIError
	// no-op method (needed to make the interface unique)
	ImplementsFuncError()
}

FuncError is an error that is the function's fault, that uses the APIError but distinguishes fault to function specific errors

type Headers

type Headers http.Header

Headers is an http.Header that implements additional methods.

func (Headers) Equals

func (h1 Headers) Equals(h2 Headers) bool

func (*Headers) Scan

func (h *Headers) Scan(value interface{}) error

Scan implements sql.Scanner

func (Headers) Value

func (h Headers) Value() (driver.Value, error)

Value implements sql.Valuer, returning a string

type MilliCPUs

type MilliCPUs uint64

MilliCPUs MilliCPU units

func (*MilliCPUs) MarshalJSON

func (c *MilliCPUs) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (MilliCPUs) String

func (c MilliCPUs) String() string

String implements fmt.Stringer

func (*MilliCPUs) UnmarshalJSON

func (c *MilliCPUs) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type ResourceConfig

type ResourceConfig struct {
	// Memory is the amount of memory allotted, in MB.
	Memory uint64 `json:"memory,omitempty" db:"memory"`
	// Timeout is the max execution time for a function, in seconds.
	// TODO this should probably be milliseconds?
	Timeout int32 `json:"timeout,omitempty" db:"timeout"`
	// IdleTimeout is the
	// TODO this should probably be milliseconds
	IdleTimeout int32 `json:"idle_timeout,omitempty" db:"idle_timeout"`
}

ResourceConfig specified resource constraints imposed on a function execution.

type Trigger

type Trigger struct {
	ID          string          `json:"id" db:"id"`
	Name        string          `json:"name" db:"name"`
	AppID       string          `json:"app_id" db:"app_id"`
	FnID        string          `json:"fn_id" db:"fn_id"`
	CreatedAt   common.DateTime `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt   common.DateTime `json:"updated_at,omitempty" db:"updated_at"`
	Type        string          `json:"type" db:"type"`
	Source      string          `json:"source" db:"source"`
	Annotations Annotations     `json:"annotations,omitempty" db:"annotations"`
}

Trigger represents a binding between a Function and an external event source

func (*Trigger) Clone

func (t *Trigger) Clone() *Trigger

Clone creates a deep copy of a trigger

func (*Trigger) Equals

func (t *Trigger) Equals(t2 *Trigger) bool

Equals compares two triggers for semantic equality it ignores timestamp fields but includes annotations

func (*Trigger) EqualsWithAnnotationSubset

func (t *Trigger) EqualsWithAnnotationSubset(t2 *Trigger) bool

EqualsWithAnnotationSubset is equivalent to Equals except it accepts cases where t's annotations are strict subset of t2

func (*Trigger) Update

func (t *Trigger) Update(patch *Trigger)

Update applies a change to a trigger

func (*Trigger) Validate

func (t *Trigger) Validate() error

Validate checks that trigger has valid data for inserting into a store

func (*Trigger) ValidateName

func (t *Trigger) ValidateName() error

type TriggerFilter

type TriggerFilter struct {
	//AppID searches for triggers in APP - mandatory
	AppID string // this is exact match mandatory
	//FNID searches for triggers belonging to a specific function
	FnID string // this is exact match
	//Name is the name of the trigger
	Name string // exact match

	Cursor  string
	PerPage int
}

TriggerFilter is a search criteria on triggers

type TriggerList

type TriggerList struct {
	NextCursor string     `json:"next_cursor,omitempty"`
	Items      []*Trigger `json:"items"`
}

TriggerList is a container of triggers returned by search, optionally indicating the next page cursor

Jump to

Keyboard shortcuts

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