runner

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerRunner

type ContainerRunner interface {
	PullImage(string) error
	RunContainer(string) (string, error)
	ContainerIP(context.Context, string) (string, error)
}

ContainerRunner handles getting the function code, starting it in a container and getting the IP address of the container to interact with it

type DockerRunner

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

DockerRunner implements ContainerRunner and uses the Docker SDK to pull images and run function code in a Docker container

func NewDockerRunner

func NewDockerRunner(registryUsername string, registryPassword string) (*DockerRunner, error)

NewDockerRunner initializes a DockerRunner with a Docker API version and credentials to access a Dockerhub registry

func (DockerRunner) ContainerIP

func (d DockerRunner) ContainerIP(ctx context.Context, id string) (string, error)

ContainerIP returns the IP address of a running Docker container

func (DockerRunner) LogOutputToConsole

func (d DockerRunner) LogOutputToConsole(ctx context.Context, id string) error

output the container logs to the console

func (DockerRunner) PullImage

func (d DockerRunner) PullImage(name string) error

PullImage downloads a container image from Dockerhub

func (DockerRunner) RunContainer

func (d DockerRunner) RunContainer(image string) (string, error)

RunContainer creates and starts a container from a local image

type HTTPPoster added in v0.4.0

type HTTPPoster interface {
	Post(string, string, io.Reader) (*http.Response, error)
}

type Runner added in v0.4.0

type Runner struct {
	CR     ContainerRunner
	Client HTTPPoster
}

Runner handles starting up the function code in a container, sending an HTTP request to invoke the function, and returning the response of the function back to the caller

func NewRunner added in v0.4.0

func NewRunner(cr ContainerRunner, c HTTPPoster) Runner

func (Runner) SendRequestToContainer added in v0.4.0

func (r Runner) SendRequestToContainer(url string, input []byte) (string, error)

SendRequestToContainer sends an HTTP request to the containers IP and tells the container to start running the function code

func (Runner) StartFnContainer added in v0.4.0

func (r Runner) StartFnContainer(image string) (string, error)

StartFnContainer starts a container containing the function code and returns the IP address of the container so that the function can be invoked via HTTP request

func (Runner) TriggerContainerFn added in v0.4.0

func (r Runner) TriggerContainerFn(ip string, input []byte) (output string, err error)

TriggerContainer will tell the container to run function code once the container is running and ready and gets the output of the function to return back to the caller

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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