ephemera

package module
v0.0.0-...-75cf154 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2015 License: MIT Imports: 10 Imported by: 0

README

Ephemera

Ephemera is a reverse proxy for ephemeral Docker containers.

When requested, it create a new container (with a TTL), assign a custom id, and proxy request to it. Once the TTL time is elapsed, it will simply kill and remove the container (and stop proxy request to it).

Used in production to generate private test instance with a 30min TTL for Blobs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	Name      string
	ID        string
	Image     string
	IP        string
	Proxy     http.Handler
	Started   bool
	StartedAt time.Time
	TTL       time.Duration
	Config    *dockerclient.ContainerConfig
	// contains filtered or unexported fields
}

Container represents a ephemeral container.

func (*Container) Kill

func (c *Container) Kill()

Kill stops and removes the container.

func (*Container) Start

func (c *Container) Start()

Start actually start the container

func (*Container) String

func (c *Container) String() string

String implements fmt.Stringer

func (*Container) WaitKill

func (c *Container) WaitKill()

WaitKill blocks till the TTL is elapsed and kill the container.

type Ephemera

type Ephemera struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(dockerURI, image string, ttl time.Duration) (*Ephemera, error)

New initializes a new Ephemera instance.

func (*Ephemera) KillAll

func (e *Ephemera) KillAll()

KillAll kills all the spawned containers still alive.

func (*Ephemera) NewContainer

func (e *Ephemera) NewContainer(img string, ttl time.Duration) *Container

Spawn a new container with the given Docker image and TTL. The container will be killed only if WaitKill/Kill is called manually.

func (*Ephemera) RegisterHandler

func (e *Ephemera) RegisterHandler(r *mux.Router)

RegisterHandler registers /demo/new and /demo/{id} routes.

Jump to

Keyboard shortcuts

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