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 DockerClient ¶
type DockerClient interface { ImagePull(context.Context, string, types.ImagePullOptions) (io.ReadCloser, error) ContainerStart(context.Context, string, types.ContainerStartOptions) error ContainerCreate(context.Context, *container.Config, *container.HostConfig, *network.NetworkingConfig, string) (container.ContainerCreateCreatedBody, error) ContainerInspect(context.Context, string) (types.ContainerJSON, error) ContainerWait(context.Context, string, container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) ContainerLogs(context.Context, string, types.ContainerLogsOptions) (io.ReadCloser, error) }
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 ¶
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 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
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
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
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