Documentation ¶
Index ¶
- Constants
- type Function
- func (fn *Function) Build() error
- func (fn *Function) CleanupArtifacts() error
- func (fn *Function) CleanupOldArtifacts() error
- func (fn *Function) GetEnv() []string
- func (fn *Function) GetHandler() string
- func (fn *Function) GetImageLatestTag() string
- func (fn *Function) GetImageName() string
- func (fn *Function) GetImageTag() string
- func (fn *Function) Invoke(input []byte) (int, []byte, error)
- func (fn *Function) IsStarted(imageName string) bool
- func (fn *Function) Load() error
- func (fn *Function) Pull() error
- func (fn *Function) PullParentImageDueNow() bool
- func (fn *Function) PullParentImageDuration() time.Duration
- func (fn *Function) Restart(containerId string) (string, error)
- func (fn *Function) RuntimesAvailable() ([]string, error)
- func (fn *Function) SetParentImageLastPulledAt()
- func (fn *Function) SetUpdatedAt()
- func (fn *Function) Start(imageName string) (string, error)
- func (fn *Function) StartIfNotStarted(imageName string) (string, error)
- func (fn *Function) Unload() error
- func (fn *Function) Validate() error
- func (fn *Function) Watch() error
- type FunctionOption
- func WithBasePath(basePath string) FunctionOption
- func WithContext(ctx context.Context) FunctionOption
- func WithDockerClient(client *docker.DockerClient) FunctionOption
- func WithName(name string) FunctionOption
- func WithRunContext(runContext context.Context) FunctionOption
- func WithRuntime(runtime string) FunctionOption
- func WithStartTimeoutInSeconds(timeoutInSeconds int) FunctionOption
- type Version
Constants ¶
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"` StartTimeoutInSeconds int `json:"start_timeout_in_seconds"` // 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"` // Flowpipe run context (e.g. for logging) BasePath string `json:"base_path"` // 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) CleanupArtifacts ¶
Cleanup all docker containers and images for all versions of the given function.
func (*Function) CleanupOldArtifacts ¶
func (*Function) GetHandler ¶
GetHandler returns the handler for the function.
func (*Function) GetImageLatestTag ¶
GetImageLatestTag returns the latest stream docker tag name (e.g. flowpipe/my_func:latest) for the function.
func (*Function) GetImageName ¶
GetImageName returns the docker image name (e.g. flowpipe/my_func) for the function.
func (*Function) GetImageTag ¶
GetImageTag returns the docker tag name (e.g. flowpipe/my_func:20230704150029969) for the function.
func (*Function) Pull ¶
Pull the fnuration of this function from its source location, e.g. GitHub or S3.
func (*Function) PullParentImageDueNow ¶
func (*Function) PullParentImageDuration ¶
func (*Function) RuntimesAvailable ¶
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) StartIfNotStarted ¶
type FunctionOption ¶
Option defines a function signature for fnuring the Docker client.
func WithBasePath ¶ added in v0.8.1
func WithBasePath(basePath string) FunctionOption
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
func WithStartTimeoutInSeconds ¶ added in v0.8.0
func WithStartTimeoutInSeconds(timeoutInSeconds int) 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 ¶
GetImageName returns the docker image name for the function.