allocations

package
v0.0.0-...-b966cd9 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocation

type Allocation struct {
	Name      string                 `json:"Name" `
	Logs      []interface{}          `json:"Logs"`
	Cron      string                 `json:"Cron"`
	CronExpr  *cronexpr.Expression   `json:"-"`
	Container CreateContainerOptions `json:"Container"`
}

The internal structure used to track and configure scheduled containers

func NewAllocation

func NewAllocation(newAllocation *AllocationSpecification) *Allocation

func (*Allocation) ShouldRunAt

func (allocation *Allocation) ShouldRunAt(atTime time.Time) bool

type AllocationSpecification

type AllocationSpecification struct {
	Name      string                 `json:"Name" yaml:"Name" binding:"required"`
	Cron      string                 `json:"Cron"  yaml:"Cron" binding:"required"`
	Container CreateContainerOptions `json:"Container" yaml:"Container" binding:"required"`
}

The request object sent to the server to define how and when a Container should be run

func (*AllocationSpecification) ProvisionDefaults

func (newAllocation *AllocationSpecification) ProvisionDefaults()

func (AllocationSpecification) Validate

func (allocation AllocationSpecification) Validate(errors *binding.Errors, req *http.Request)

type AllocationStore

type AllocationStore interface {
	// Get a list of all allocations
	List() (Allocations, error)

	// Get the allocation by name.
	// will return an error if it can't be found
	Get(name string) (*Allocation, error)

	// Delete an allocation by name
	// will return an error if it can't be found
	Delete(name string) error

	// If an allocation exists with the given name,
	// update the values of that allocation.
	// Otherwise create a new one. Returns whether a
	// new allocation was created.
	CreateOrUpdate(allocation *AllocationSpecification) (bool, error)

	// Log an event regarding an exiting specification
	Log(allocation *Allocation, events ...interface{}) error
}

Abstraction on top of storing and querying The collection of allocations. Right now we'll back this with a slice, but may want to move to gkvlite or etcd or redis or whatever These are allowed to return error because other implementations may include IO calls

type Allocations

type Allocations []*Allocation

type CreateContainerOptions

type CreateContainerOptions struct {
	Config           *docker.Config           `qs:"-" json:"Config" yaml:"Config"`
	HostConfig       *docker.HostConfig       `qs:"-" json:"HostConfig" yaml:"HostConfig"`
	NetworkingConfig *docker.NetworkingConfig `qs:"-" json:"NetworkingConfig" yaml:"NetworkingConfig"`
}

copy of docker.CreateContainerOptions, but with no name or context, and some custom yaml binding

func (CreateContainerOptions) ToOptions

func (opts CreateContainerOptions) ToOptions() docker.CreateContainerOptions

type InMemoryAllocations

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

func InMemory

func InMemory() *InMemoryAllocations

InMemory creates a new allocationStore backed by a slice

func (*InMemoryAllocations) CreateOrUpdate

func (a *InMemoryAllocations) CreateOrUpdate(newAllocation *AllocationSpecification) (bool, error)

func (*InMemoryAllocations) Delete

func (a *InMemoryAllocations) Delete(name string) error

func (*InMemoryAllocations) Get

func (a *InMemoryAllocations) Get(name string) (*Allocation, error)

func (*InMemoryAllocations) List

func (a *InMemoryAllocations) List() (Allocations, error)

func (*InMemoryAllocations) Log

func (a *InMemoryAllocations) Log(allocation *Allocation, events ...interface{}) error

Jump to

Keyboard shortcuts

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