container

package
v1.0.0-percom23 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CUSTOM_RUNTIME = "custom"

Variables

View Source
var RuntimeToInfo = map[string]RuntimeInfo{
	"python310":  RuntimeInfo{"grussorusso/serverledge-python310", []string{"python", "/entrypoint.py"}},
	"nodejs17":   RuntimeInfo{"grussorusso/serverledge-nodejs17", []string{"node", "/entrypoint.js"}},
	"nodejs17ng": RuntimeInfo{"grussorusso/serverledge-nodejs17ng", []string{}},
}

Functions

func Destroy

func Destroy(id ContainerID) error

func Execute

Execute interacts with the Executor running in the container to invoke the function through a HTTP request.

func GetMemoryMB

func GetMemoryMB(id ContainerID) (int64, error)

Types

type ContainerID

type ContainerID = string

func NewContainer

func NewContainer(image, codeTar string, opts *ContainerOptions) (ContainerID, error)

NewContainer creates and starts a new container.

type ContainerOptions

type ContainerOptions struct {
	Cmd      []string
	Env      []string
	MemoryMB int64
}

ContainerOptions contains options for container creation.

type DockerFactory

type DockerFactory struct {
	// contains filtered or unexported fields
}

func InitDockerContainerFactory

func InitDockerContainerFactory() *DockerFactory

func (*DockerFactory) CopyToContainer

func (cf *DockerFactory) CopyToContainer(contID ContainerID, content io.Reader, destPath string) error

func (*DockerFactory) Create

func (cf *DockerFactory) Create(image string, opts *ContainerOptions) (ContainerID, error)

func (*DockerFactory) Destroy

func (cf *DockerFactory) Destroy(contID ContainerID) error

func (*DockerFactory) GetIPAddress

func (cf *DockerFactory) GetIPAddress(contID ContainerID) (string, error)

func (*DockerFactory) GetMemoryMB

func (cf *DockerFactory) GetMemoryMB(contID ContainerID) (int64, error)

func (*DockerFactory) HasImage

func (cf *DockerFactory) HasImage(image string) bool

func (*DockerFactory) Start

func (cf *DockerFactory) Start(contID ContainerID) error

type Factory

type Factory interface {
	Create(string, *ContainerOptions) (ContainerID, error)
	CopyToContainer(ContainerID, io.Reader, string) error
	Start(ContainerID) error
	Destroy(ContainerID) error
	HasImage(string) bool
	GetIPAddress(ContainerID) (string, error)
	GetMemoryMB(id ContainerID) (int64, error)
}

A Factory to create and manage container.

type RuntimeInfo

type RuntimeInfo struct {
	Image         string
	InvocationCmd []string
}

RuntimeInfo contains information about a supported function runtime env.

Jump to

Keyboard shortcuts

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