function

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPullParentImagePeriod defines the default period for pulling the
	// parent image.
	DefaultPullParentImagePeriod = "24h"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Function

type Function struct {

	// fnuration information
	Name    string                 `json:"name"`
	Runtime string                 `json:"runtime"`
	Handler string                 `json:"handler"`
	Source  string                 `json:"source"`
	Env     map[string]string      `json:"env"`
	Event   map[string]interface{} `json:"event"`
	Timeout *int64                 `json:"timeout"`

	// PullParentImagePeriod defines how often the parent image should be pulled.
	// This is useful for keeping the parent image up to date. Default is every
	// 24hrs. Accepts any valid golang duration string.
	PullParentImagePeriod string `json:"pull_parent_image_period"`

	// Runtime information
	AbsolutePath            string             `json:"absolute_path"`
	CreatedAt               *time.Time         `json:"created_at,omitempty"`
	UpdatedAt               *time.Time         `json:"updated_at,omitempty"`
	ParentImageLastPulledAt *time.Time         `json:"-"`
	CurrentVersionName      string             `json:"current_version_name"`
	Versions                map[string]Version `json:"versions"`
	// contains filtered or unexported fields
}

func New

func New(options ...FunctionOption) (*Function, error)

New creates a new Function fn with the provided options.

func (*Function) Build

func (fn *Function) Build() error

func (*Function) CleanupArtifacts

func (fn *Function) CleanupArtifacts() error

Cleanup all docker containers and images for all versions of the given function.

func (*Function) CleanupOldArtifacts

func (fn *Function) CleanupOldArtifacts() error

func (*Function) GetEnv

func (fn *Function) GetEnv() []string

func (*Function) GetHandler

func (fn *Function) GetHandler() string

GetHandler returns the handler for the function.

func (*Function) GetImageLatestTag

func (fn *Function) GetImageLatestTag() string

GetImageLatestTag returns the latest stream docker tag name (e.g. flowpipe/my_func:latest) for the function.

func (*Function) GetImageName

func (fn *Function) GetImageName() string

GetImageName returns the docker image name (e.g. flowpipe/my_func) for the function.

func (*Function) GetImageTag

func (fn *Function) GetImageTag() string

GetImageTag returns the docker tag name (e.g. flowpipe/my_func:20230704150029969) for the function.

func (*Function) Invoke

func (fn *Function) Invoke(input []byte) (int, []byte, error)

func (*Function) IsStarted

func (fn *Function) IsStarted(imageName string) bool

func (*Function) Load

func (fn *Function) Load() error

Load loads the function fn.

func (*Function) Pull

func (fn *Function) Pull() error

Pull the fnuration of this function from its source location, e.g. GitHub or S3.

func (*Function) PullParentImageDueNow

func (fn *Function) PullParentImageDueNow() bool

func (*Function) PullParentImageDuration

func (fn *Function) PullParentImageDuration() time.Duration

func (*Function) Restart

func (fn *Function) Restart(containerID string) (string, error)

func (*Function) RuntimesAvailable

func (fn *Function) RuntimesAvailable() ([]string, error)

RuntimesAvailable returns a list of available runtimes based on those defined in the runtimes directory.

func (*Function) SetParentImageLastPulledAt

func (fn *Function) SetParentImageLastPulledAt()

SetParentImageLastPulledAt sets the ParentImageLastPulledAt to the current time.

func (*Function) SetUpdatedAt

func (fn *Function) SetUpdatedAt()

SetUpdatedAt sets the updated at time.

func (*Function) Start

func (fn *Function) Start(imageName string) (string, error)

func (*Function) StartIfNotStarted

func (fn *Function) StartIfNotStarted(imageName string) (string, error)

func (*Function) Unload

func (fn *Function) Unload() error

Unload unloads the function fn.

func (*Function) Validate

func (fn *Function) Validate() error

Validate validates the function fn.

func (*Function) Watch

func (fn *Function) Watch() error

type FunctionOption

type FunctionOption func(*Function) error

Option defines a function signature for fnuring the Docker client.

func WithContext

func WithContext(ctx context.Context) FunctionOption

WithContext fnures the Docker client with a specific context.

func WithDockerClient

func WithDockerClient(client *docker.DockerClient) FunctionOption

WithFunctionDockerClient fnures the Docker client.

func WithName added in v0.2.0

func WithName(name string) FunctionOption

func WithRunContext

func WithRunContext(runContext context.Context) FunctionOption

func WithRuntime added in v0.2.0

func WithRuntime(runtime string) FunctionOption

type Version

type Version struct {

	// Configuration
	Tag          string    `json:"tag"`
	Port         string    `json:"port"`
	ContainerIDs []string  `json:"container_ids"`
	Status       string    `json:"status"`
	CreatedAt    time.Time `json:"created_at"`

	// Runtime information
	Function    *Function `json:"-"`
	BuildQueued bool      `json:"build_queued"`
}

func (*Version) GetImageTag

func (v *Version) GetImageTag() string

GetImageName returns the docker image name for the function.

func (*Version) LambdaEndpoint

func (v *Version) LambdaEndpoint() string

Jump to

Keyboard shortcuts

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