metaparticle

package
v0.0.0-...-3154e75 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Containerize

func Containerize(r *Runtime, p *Package, f func())

Containerize receives a description of the runtime and metadata needed to build a container image, and run it.

When called inside the container, it runs the function f. When called outside the container, it builds the container image and runs it in the specified runtime environment.

Types

type ACIExecutor

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

ACIExecutor implements and executor on Azure Container Engine

func NewACIExecutor

func NewACIExecutor() (*ACIExecutor, error)

NewACIExecutor returns a new instance of an ACI Executor

func (*ACIExecutor) Cancel

func (a *ACIExecutor) Cancel(name string) error

Cancel deletes the container with the given name on the executor's resource group

func (*ACIExecutor) Logs

func (a *ACIExecutor) Logs(name string, stdout io.Writer, stderr io.Writer) error

Logs shows the logs of the container with the given name on the azure executor's resource group

func (*ACIExecutor) Run

func (a *ACIExecutor) Run(image string, name string, cfg *Runtime, stdout io.Writer, stderr io.Writer) error

Run creates a container on the azure executor's resource group using the given image and name

type ACIRuntimeConfig

type ACIRuntimeConfig struct {
	SubscriptionID string
	TenantID       string
	ClientID       string
	ClientSecret   string

	ResourceGroupName string
}

ACIRuntimeConfig - runtime config for ACI executor.

type Builder

type Builder interface {
	Build(dir string, image string, stdout io.Writer, stderr io.Writer) error
	Push(image string, stdout io.Writer, stderr io.Writer) error
}

Builder is the interface that wraps the container runtime's build and push methods

type DockerImpl

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

DockerImpl is a docker implementation of the Builder and Executor interfaces

func NewDockerImpl

func NewDockerImpl() (*DockerImpl, error)

NewDockerImpl returns a singleton struct that uses docker to implement metaparticle.Builder and metaparticle.Executor.

It uses the environment variables DOCKER_CERT_PATH, DOCKER_HOST, DOCKER_API_VERSION and DOCKER_TLS_VERIFY to instantiate instantiate a docker API client. When these variables are not specified, it defaults to the client running on the local machine.

func (*DockerImpl) Build

func (d *DockerImpl) Build(dir string, image string, stdout io.Writer, stderr io.Writer) error

Build creates a tarball with the directory's contents and sends it to docker to be build the image

func (*DockerImpl) Cancel

func (d *DockerImpl) Cancel(name string) error

Cancel stops and removes the container with the given name

func (*DockerImpl) Logs

func (d *DockerImpl) Logs(name string, stdout io.Writer, stderr io.Writer) error

Logs attaches to the container with the given name and prints the log to stdout

func (*DockerImpl) Push

func (d *DockerImpl) Push(image string, stdout io.Writer, stderr io.Writer) error

Push pushes the image to the docker registry

func (*DockerImpl) Run

func (d *DockerImpl) Run(image string, name string, config *Runtime, stdout io.Writer, stderr io.Writer) error

Run creates and starts a container with the given image and name, and runtime options (e.g. exposed ports) specified in the config parameter

type Executor

type Executor interface {
	Run(image string, name string, config *Runtime, stdout io.Writer, stderr io.Writer) error
	Logs(name string, stdout io.Writer, stderr io.Writer) error
	Cancel(name string) error
}

Executor implementors are container platforms where the containers can be deployed (e.g. Azure, GCP)

type MetaparticleExecutor

type MetaparticleExecutor struct {
	SpecPath string
}

func (*MetaparticleExecutor) Cancel

func (m *MetaparticleExecutor) Cancel(name string) error

func (*MetaparticleExecutor) Logs

func (m *MetaparticleExecutor) Logs(name string, stdout io.Writer, stderr io.Writer) error

func (*MetaparticleExecutor) Run

func (m *MetaparticleExecutor) Run(image string, name string, config *Runtime, stdout io.Writer, stderr io.Writer) error

type Package

type Package struct {
	// Image name
	Name string
	// Image repository (e.g. quay.io/user)
	Repository string
	Verbose    bool
	Quiet      bool
	// Image builder (e.g. docker)
	Builder string
	// Whether to publish the built image to the remote repository
	Publish bool
}

Package encapsulates the metadata needed to build the image

type Runtime

type Runtime struct {
	// must return an integer >= 1
	Replicas int32

	// must return an integer >= 0
	Shards int32

	// TODO: find out what this does
	URLShardPattern string

	// The name of the executor (e.g.: docker)
	Executor string

	// Returns the ports that the service exposes
	Ports []int32

	// Returns whether the service wants a public IP when deployed (usually involves the creation of a load balancer)
	PublicAddress bool

	// Pointer to extra configuration needed by specific executors (e.g. AciRuntimeConfig)
	ExtraConfig interface{}
}

Runtime represents a place where to run the containers (Docker, rkt, etc)

Directories

Path Synopsis
test-data

Jump to

Keyboard shortcuts

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