engine

package
v0.0.0-...-d69b078 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const LatestHashVersion = 1

Latest version of our hash TODO: should auto calculate...

Variables

View Source
var ErrCircularDependency = errors.New("circular dependecy detected")

ErrCircularDependency ...

View Source
var ErrConfigDecoderFailed = errors.New("config decoder failed")

ErrConfigDecoderFailed

View Source
var ErrInvalidPayload = errors.New("not a valid payload")

ErrInvalidPayload ...

View Source
var ErrLoopDetected = errors.New("loop detected")

ErrLoopDetected

View Source
var ErrNoConfigDecoder = errors.New("config entry has no config decoder")

ErrNoConfigDecoder

View Source
var ErrNoContainerRuntime = errors.New("no container runtime started")

ErrNoContainerRuntime ...

View Source
var ErrNotAConfig = errors.New("not a config object")

ErrNotAConfig ...

View Source
var ErrNotAConfigStructure = errors.New("not a propper structure")

ErrNotAConfigStructure

View Source
var ErrNotAValidConfig = errors.New("not a valid config")

ErrNotAValidConfig ...

View Source
var ErrNotAllowed = errors.New("action not allowed")

ErrNotAllowed ...

View Source
var ErrUnknownEvent = errors.New("unknown event")

ErrUnknownEvent ...

Functions

func RegisterAction

func RegisterAction(name string, creator NewAction)

RegisterAction is called to register an Action object

func RegisterConfStore

func RegisterConfStore(name string, creator NewConfStore)

RegisterConfStore registers a ConfStore with the engine.

func RegisterConfigDecoder

func RegisterConfigDecoder(name string, cd ConfigDecoder)

RegisterConfigDecoder registers a ConfigDecoder with the engine.

func RegisterContainerRuntime

func RegisterContainerRuntime(name string, creator NewContainerRuntime)

RegisterContainerRuntime is called to register a ContainerRuntime object

func RegisterReaction

func RegisterReaction(name string, creator NewReaction)

RegisterReaction is called to register a Reaction object

Types

type Action

type Action interface {
	Setup
	StartStop
	Add() error
	Remove() error
	RemoveAll() error
}

Action interface. because even interfaces need some action once in a while.

type Command

type Command struct {
	Name        string
	Source      *NameSpace
	Destination *NameSpace
	Payload     interface{}
}

Command object for communicating through the engine.

type Commander

type Commander interface {
	Command(cmd *Command) error
}

Commander interface

type ConfStore

type ConfStore interface {
	Setup
	StartStop
}

ConfStore is the interface for every config store module.

type Config

type Config interface {
	Target() *NameSpace
	Version() int
	Hash() string
}

Config is the interface for every module Config object.

type ConfigDecoder

type ConfigDecoder interface {
	DecodeConfig(cont interface{}) (Config, error)
}

ConfigDecoder is an interface to parsing and validating configuration data

type Container

type Container interface {
	Commander
}

Container is the interface for containers.

type ContainerData

type ContainerData struct {
	ID      string
	Name    string
	Created time.Time
	// Args    []string
	Network *ContainerNetwork
}

ContainerData holds information about a container for communicating with modules.

func NewContainerData

func NewContainerData() *ContainerData

NewContainerData returns an empty ContainerData object.

type ContainerNetwork

type ContainerNetwork struct {
	IPAddress  string
	Mask       int
	Ports      []Port
	Published  map[Port][]Published
	Hostname   string
	Domainname string
	DNS        []string
}

ContainerNetwork holds network information about a container.

type ContainerRuntime

type ContainerRuntime interface {
	Setup
	StartStop
	Commander
}

ContainerRuntime is the interface for the container runtine object.

type Engine

type Engine struct {
	Config map[string]Config

	ContainerRuntime ContainerRuntime
	ContainerList    map[string]Container
	FileStore        ConfStore
	ConfStore        ConfStore
	Action           map[string]Action
	Reaction         map[string]Reaction
	// contains filtered or unexported fields
}

Engine is the heart of stacker, it runs everything.

func New

func New() (*Engine, error)

New creates a new Engine object, and returns it.

func (*Engine) DeregisterContainer

func (e *Engine) DeregisterContainer(name string) error

DeregisterContainer registers an action on the container list

func (*Engine) Event

func (e *Engine) Event(cmd *Command) error

Event triggers an incoming event TODO: clean up

func (*Engine) Initialize

func (e *Engine) Initialize() error

Initialize the engine

func (*Engine) RegisterContainer

func (e *Engine) RegisterContainer(name string, c Container) error

RegisterContainer registers an container on the container list

func (*Engine) Restart

func (e *Engine) Restart() error

Restart the engine.

func (*Engine) SetConfigFile

func (e *Engine) SetConfigFile(cfgfile string) error

SetConfigFile sets the path to the config file

func (*Engine) Start

func (e *Engine) Start() error

Start the engine

func (*Engine) State

func (e *Engine) State() error

State gives a dump of the engine state This is for testing, and will be removes.

func (*Engine) Stop

func (e *Engine) Stop() error

Stop the engine

type Event

type Event int

Event type

type NameSpace

type NameSpace struct {
	Type   string
	Module string
	ID     string
}

NameSpace object holds the namespace information for different modules.

func (*NameSpace) String

func (ns *NameSpace) String() string

String returns a string representation of a NameSpace.

type NewAction

type NewAction func() (a Action)

NewAction is a function definition each Action must provide

type NewConfStore

type NewConfStore func() (c ConfStore)

NewConfStore is a function definition each ConfStore must provide

type NewContainerRuntime

type NewContainerRuntime func() (c ContainerRuntime)

NewContainerRuntime is a function definition each Docker must provide

type NewReaction

type NewReaction func() (r Reaction)

NewReaction is a function definition each Reaction must provide

type Port

type Port string

Port is a port number. the format is fe 80/tcp or 53/udp

func (Port) Port

func (p Port) Port() uint16

Port returns the port number as an integer.

func (Port) Proto

func (p Port) Proto() string

Proto returns the protocol as a string. at this time, only tcp and udp are supported.

type Published

type Published struct {
	IP   net.IP
	Port uint16
}

Published is a published port, with the ip and port it is published to.

type Reaction

type Reaction interface {
	Setup
	StartStop
	Commander
}

Reaction interface. It interfaces reactions! to things...

type Setup

type Setup interface {
	Setup(eng *Engine, cfg Config) error
}

Setup interface

type StartStop

type StartStop interface {
	Start() error
	Stop() error
}

StartStop interface

Jump to

Keyboard shortcuts

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