model

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2015 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionCreated = Action(1)
	ActionRemoved = Action(2)
	ActionUpdate  = Action(3)
)

Variables

View Source
var DatabaseMetaKey = "_db"
View Source
var DefaultIsolationID = "default"
View Source
var DefaultStateID = "default"
View Source
var DepBucketName = "deps"
View Source
var (
	FirstDep = Milestone{"first_dep", func(s *Stats) bool {
		return s.NrOfDepsCreated > 0
	}, false}
)
View Source
var IsolationBucketName = "isolations"
View Source
var MetaBucketName = "meta"
View Source
var StatsMetaKey = "_stats"

Functions

This section is empty.

Types

type Action

type Action int

type Build added in v0.2.1

type Build struct {
	ID        string  `json:"id"`
	State     State   `json:"state"`
	Dep       Dep     `json:"dep"`
	Error     error   `json:"error"`
	ImageName string  `json:"image_name"`
	IsRunning bool    `json:"is_running"`
	Output    *Output `json:"output"`
}

func NewBuild added in v0.2.1

func NewBuild(d Dep, s State) (*Build, error)

type Dep

type Dep struct {
	ID       string    `json:"id"`
	Name     string    `json:"name"`
	States   []*State  `json:"states"`
	Template *Template `json:"template"`
}

func NewDep

func NewDep(name string, t *Template) (*Dep, error)

func NewDepFromSerialized

func NewDepFromSerialized(data []byte) (*Dep, error)

func (*Dep) AddState

func (d *Dep) AddState(s *State)

func (*Dep) GetState

func (d *Dep) GetState(sid string) *State

func (*Dep) Serialize

func (i *Dep) Serialize() ([]byte, error)

func (*Dep) UpdateState added in v0.2.1

func (d *Dep) UpdateState(oldstate *State, newstate *State)

type Duration added in v0.3.1

type Duration time.Duration

A JSON Serializable time duration

func (Duration) MarshalJSON added in v0.3.1

func (d Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalJSON added in v0.3.1

func (d *Duration) UnmarshalJSON(data []byte) error

type Event

type Event struct {
	Action  Action
	Subject interface{}
}

func NewEvent

func NewEvent(a Action, s interface{}) Event

type File added in v0.4.1

type File struct {
	IsLocked bool   `json:"is_locked"`
	Content  string `json:"content"`
}

type Isolation

type Isolation struct {
	ID     string            `json:"id"`
	Name   string            `json:"name"`
	States map[string]string `json:"states"`
}

func NewIsolation

func NewIsolation(name string) (*Isolation, error)

func NewIsolationFromSerialized

func NewIsolationFromSerialized(data []byte) (*Isolation, error)

func (*Isolation) AddDep

func (i *Isolation) AddDep(dep *Dep, sid string)

func (*Isolation) HasDep

func (i *Isolation) HasDep(dep *Dep) bool

func (*Isolation) HasDepState

func (i *Isolation) HasDepState(dep *Dep, sid string) bool

func (*Isolation) RemoveDep

func (i *Isolation) RemoveDep(dep *Dep)

func (*Isolation) Serialize

func (i *Isolation) Serialize() ([]byte, error)

type Meta

type Meta struct {
	ID string `json:"name"`
}

db meta struct contains meta information about the db itself

func NewMeta

func NewMeta() (*Meta, error)

func NewMetaFromSerialized

func NewMetaFromSerialized(data []byte) (*Meta, error)

func (*Meta) Serialize

func (m *Meta) Serialize() ([]byte, error)

type Milestone added in v0.4.1

type Milestone struct {
	ID         string            `json:"id"`
	IsUnlocked func(*Stats) bool `json:"-"`
	Shown      bool              `json:"shown"`
}

func Milestones added in v0.4.1

func Milestones() []Milestone

type Model

type Model struct {
	DBPath string
	Stats  *Stats
	Events chan Event

	Out []chan Event
	// contains filtered or unexported fields
}

func NewModel

func NewModel(dbpath string) (*Model, error)

func (*Model) CreateStatsIfNotExists added in v0.4.1

func (m *Model) CreateStatsIfNotExists() (*Stats, error)

func (*Model) FindDepByID added in v0.3.3

func (m *Model) FindDepByID(id string) (*Dep, error)

func (*Model) FindIsolationByID added in v0.1.2

func (m *Model) FindIsolationByID(ID string) (*Isolation, error)

func (*Model) FindIsolationByName

func (m *Model) FindIsolationByName(name string) (*Isolation, error)

func (*Model) GetAllDeps

func (m *Model) GetAllDeps() ([]*Dep, error)

func (*Model) GetAllIsolations

func (m *Model) GetAllIsolations() ([]*Isolation, error)

func (*Model) GetDBMetaData

func (m *Model) GetDBMetaData() (*Meta, error)

func (*Model) GetIsolationDepsAndStates

func (m *Model) GetIsolationDepsAndStates(iso *Isolation) (map[*Dep]*State, error)

func (*Model) InsertDep

func (m *Model) InsertDep(dep *Dep) error

func (*Model) InsertIsolation

func (m *Model) InsertIsolation(iso *Isolation) error

func (*Model) PersistStats added in v0.4.1

func (m *Model) PersistStats() error

func (*Model) RemoveDep

func (m *Model) RemoveDep(dep *Dep) error

func (*Model) RemoveDepStateByID added in v0.3.1

func (m *Model) RemoveDepStateByID(dep *Dep, sid string) error

func (*Model) RemoveIsolation

func (m *Model) RemoveIsolation(iso *Isolation) error

func (*Model) Subscribe added in v0.4.2

func (m *Model) Subscribe(ch chan Event)

func (*Model) UpdateDep

func (m *Model) UpdateDep(dep *Dep) error

func (*Model) UpdateDepWithNewState added in v0.4.1

func (m *Model) UpdateDepWithNewState(dep *Dep, sname string) error

func (*Model) UpdateIsolation

func (m *Model) UpdateIsolation(iso *Isolation) error

func (*Model) UpsertDefaultIsolationIfNotExists added in v0.4.1

func (m *Model) UpsertDefaultIsolationIfNotExists() error

func (*Model) UpsertMetadataIfNotExists added in v0.4.1

func (m *Model) UpsertMetadataIfNotExists() error

type Output added in v0.2.1

type Output struct {
	Buffer *bytes.Buffer
}

A JSON Serializable output buffer

func NewOutput added in v0.2.1

func NewOutput() *Output

func (*Output) MarshalJSON added in v0.2.1

func (o *Output) MarshalJSON() ([]byte, error)

type RegexpPattern added in v0.3.1

type RegexpPattern regexp.Regexp

A JSON Serializable regexp pattern

func (RegexpPattern) MarshalJSON added in v0.3.1

func (r RegexpPattern) MarshalJSON() ([]byte, error)

func (*RegexpPattern) UnmarshalJSON added in v0.3.1

func (r *RegexpPattern) UnmarshalJSON(data []byte) error

type Run added in v0.3.1

type Run struct {
	ID            string                      `json:"id"`
	State         State                       `json:"state"`
	ContainerID   string                      `json:"container_id"`
	Error         string                      `json:"error"`
	IsReady       bool                        `json:"is_ready"`
	Output        *Output                     `json:"output"`
	ContainerInfo *dockerclient.ContainerInfo `json:"container_info"`
}

func NewRun added in v0.3.1

func NewRun(s State) (*Run, error)

type State

type State struct {
	ID        string          `json:"id"`
	Name      string          `json:"name"`
	Files     map[string]File `json:"files"`
	Settings  *StateSettings  `json:"settings"`
	ImageName string          `json:"image_name"`
}

func NewStateFromTemplate added in v0.3.1

func NewStateFromTemplate(name string, t *Template) (*State, error)

type StateSettings added in v0.3.1

type StateSettings struct {
	ReadyTimeout    Duration                      `json:"ready_timeout"`
	ReadyPattern    *RegexpPattern                `json:"ready_pattern"`
	HostConfig      *dockerclient.HostConfig      `json:"host_config"`
	ContainerConfig *dockerclient.ContainerConfig `json:"container_config"`
}

type Stats added in v0.4.1

type Stats struct {
	NrOfDepsCreated int                  `json:"nr_of_deps_created"`
	Achievements    map[string]Milestone `json:"achievements"`
}

func NewStats added in v0.4.1

func NewStats() (*Stats, error)

func NewStatsFromSerialized added in v0.4.1

func NewStatsFromSerialized(data []byte) (*Stats, error)

func (*Stats) Handle added in v0.4.1

func (s *Stats) Handle(ev Event) bool

func (*Stats) Serialize added in v0.4.1

func (s *Stats) Serialize() ([]byte, error)

func (*Stats) UpdateAchievements added in v0.4.1

func (s *Stats) UpdateAchievements()

type Template added in v0.3.1

type Template struct {
	ID            string           `json:"id"`
	Name          string           `json:"name"`
	Icons         string           `json:"icons"`
	DefaultName   string           `json:"default_name"`
	Category      string           `json:"category"`
	Files         map[string]*File `json:"files"`
	StateSettings *StateSettings   `json:"state_settings"`
}

Jump to

Keyboard shortcuts

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