Documentation
¶
Index ¶
- Constants
- Variables
- func RoleToPB(r Role) pb.MinionConfig_Role
- type Cluster
- type Conn
- func (conn Conn) EtcdLeader() bool
- func (conn Conn) MinionSelf() (Minion, error)
- func (conn Conn) SelectFromConnection(check func(Connection) bool) []Connection
- func (conn Conn) SelectFromContainer(check func(Container) bool) []Container
- func (conn Conn) SelectFromEtcd(check func(Etcd) bool) []Etcd
- func (conn Conn) SelectFromLabel(check func(Label) bool) []Label
- func (conn Conn) SelectFromMinion(check func(Minion) bool) []Minion
- func (conn Conn) SelectFromPlacement(check func(Placement) bool) []Placement
- func (cn Conn) Transact(do func(db Database) error) error
- func (cn Conn) Trigger(tt ...TableType) Trigger
- func (cn Conn) TriggerTick(seconds int, tt ...TableType) Trigger
- type Connection
- type ConnectionSlice
- type Container
- type ContainerSlice
- type Database
- func (db Database) Commit(r row)
- func (db Database) EtcdLeader() bool
- func (db Database) GetCluster() (Cluster, error)
- func (db Database) InsertCluster() Cluster
- func (db Database) InsertConnection() Connection
- func (db Database) InsertContainer() Container
- func (db Database) InsertEtcd() Etcd
- func (db Database) InsertLabel() Label
- func (db Database) InsertMachine() Machine
- func (db Database) InsertMinion() Minion
- func (db Database) InsertPlacement() Placement
- func (db Database) MinionSelf() (Minion, error)
- func (db Database) Remove(r row)
- func (db Database) SelectFromCluster(check func(Cluster) bool) []Cluster
- func (db Database) SelectFromConnection(check func(Connection) bool) []Connection
- func (db Database) SelectFromContainer(check func(Container) bool) []Container
- func (db Database) SelectFromEtcd(check func(Etcd) bool) []Etcd
- func (db Database) SelectFromLabel(check func(Label) bool) []Label
- func (db Database) SelectFromMachine(check func(Machine) bool) []Machine
- func (db Database) SelectFromMinion(check func(Minion) bool) []Minion
- func (db Database) SelectFromPlacement(check func(Placement) bool) []Placement
- type Etcd
- type Label
- type LabelSlice
- type Machine
- type MachineSlice
- type Minion
- type MinionSlice
- type Placement
- type PlacementSlice
- type Provider
- type ProviderSlice
- type Role
- type TableType
- type Trigger
Constants ¶
const ( // None is for workers who haven't been assigned a role yet. None Role = "" // Worker minions run application containers. Worker = "Worker" // Master containers provide services for the Worker containers. Master = "Master" )
const ( // Amazon implements amazon EC2. Amazon Provider = "Amazon" // Google implements Google Cloud Engine. Google = "Google" // Vagrant implements local virtual machines. Vagrant = "Vagrant" // Azure implements the Azure cloud provider. Azure = "Azure" )
Variables ¶
var ClusterTable = TableType(reflect.TypeOf(Cluster{}).String())
ClusterTable is the type of the cluster table.
var ConnectionTable = TableType(reflect.TypeOf(Connection{}).String())
ConnectionTable is the type of the connection table.
var ContainerTable = TableType(reflect.TypeOf(Container{}).String())
ContainerTable is the type of the container table.
var EtcdTable = TableType(reflect.TypeOf(Etcd{}).String())
EtcdTable is the type of the etcd table.
var LabelTable = TableType(reflect.TypeOf(Label{}).String())
LabelTable is the type of the label table.
var MachineTable = TableType(reflect.TypeOf(Machine{}).String())
MachineTable is the type of the machine table.
var MinionTable = TableType(reflect.TypeOf(Minion{}).String())
MinionTable is the type of the minion table.
var PlacementTable = TableType(reflect.TypeOf(Placement{}).String())
PlacementTable is the type of the placement table.
Functions ¶
func RoleToPB ¶
func RoleToPB(r Role) pb.MinionConfig_Role
RoleToPB converts db.Role to a protobuf role.
Types ¶
type Cluster ¶
type Cluster struct { ID int Namespace string // Cloud Provider Namespace Spec string /* XXX: These belong in a separate administration table of some sort. */ ACLs []string }
A Cluster is a group of Machines which can operate containers.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
A Conn is a database handle on which transactions may be executed.
func (Conn) EtcdLeader ¶
EtcdLeader returns true if the minion is the lead master for the cluster.
func (Conn) MinionSelf ¶
MinionSelf returns the Minion Row corresponding to the currently running minion, or an error if no such row exists.
func (Conn) SelectFromConnection ¶
func (conn Conn) SelectFromConnection(check func(Connection) bool) []Connection
SelectFromConnection gets all connections in the database connection that satisfy the 'check'.
func (Conn) SelectFromContainer ¶
SelectFromContainer gets all containers in the database that satisfy the 'check'.
func (Conn) SelectFromEtcd ¶
SelectFromEtcd gets all Etcd rows in the database connection that satisfy the 'check'.
func (Conn) SelectFromLabel ¶
SelectFromLabel gets all labels in the database connection that satisfy 'check'.
func (Conn) SelectFromMinion ¶
SelectFromMinion gets all minions in the database that satisfy the 'check'.
func (Conn) SelectFromPlacement ¶
SelectFromPlacement gets all placements in the database that satisfy the 'check'.
func (Conn) Transact ¶
Transact executes database transactions. It takes a closure, 'do', which is operates on its 'db' argument. Transactions are not concurrent, instead each runs sequentially on it's database without conflicting with other transactions.
type Connection ¶
A Connection allows the members of two labels to speak to each other on the port range [MinPort, MaxPort] inclusive.
func (Connection) String ¶
func (c Connection) String() string
type ConnectionSlice ¶
type ConnectionSlice []Connection
ConnectionSlice is an alias for []Connection to allow for joins
func (ConnectionSlice) Get ¶
func (cs ConnectionSlice) Get(ii int) interface{}
Get returns the value contained at the given index
func (ConnectionSlice) Len ¶
func (cs ConnectionSlice) Len() int
Len returns the number of items in the slice.
type Container ¶
type Container struct { ID int Pid int IP string Mac string Minion string DockerID string StitchID int Image string Command []string Labels []string Env map[string]string }
A Container row is created for each container specified by the policy. Each row will eventually be instantiated within its corresponding cluster. Used only by the minion.
type ContainerSlice ¶
type ContainerSlice []Container
ContainerSlice is an alias for []Container to allow for joins
func (ContainerSlice) Get ¶
func (cs ContainerSlice) Get(ii int) interface{}
Get returns the value contained at the given index
func (ContainerSlice) Len ¶
func (cs ContainerSlice) Len() int
Len returns the number of items in the slice
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
The Database is the central storage location for all state in the system. The policy engine populates the database with a preferred state of the world, while various modules flesh out that policy with actual implementation details.
func (Database) Commit ¶
func (db Database) Commit(r row)
Commit updates the database with the data contained in row.
func (Database) EtcdLeader ¶
EtcdLeader returns true if the minion is the lead master for the cluster.
func (Database) GetCluster ¶
GetCluster gets the cluster from the database. There should only ever be a single cluster.
func (Database) InsertCluster ¶
InsertCluster creates a new Cluster and interts it into 'db'.
func (Database) InsertConnection ¶
func (db Database) InsertConnection() Connection
InsertConnection creates a new connection row and inserts it into the database.
func (Database) InsertContainer ¶
InsertContainer creates a new container row and inserts it into the database.
func (Database) InsertEtcd ¶
InsertEtcd creates a new etcd row and inserts it into the database.
func (Database) InsertLabel ¶
InsertLabel creates a new label row and inserts it into the database.
func (Database) InsertMachine ¶
InsertMachine creates a new Machine and inserts it into 'db'.
func (Database) InsertMinion ¶
InsertMinion creates a new Minion and inserts it into 'db'.
func (Database) InsertPlacement ¶
InsertPlacement creates a new placement row and inserts it into the database.
func (Database) MinionSelf ¶
MinionSelf returns the Minion Row corresponding to the currently running minion, or an error if no such row exists.
func (Database) SelectFromCluster ¶
SelectFromCluster gets all clusters in the database that satisfy 'check'.
func (Database) SelectFromConnection ¶
func (db Database) SelectFromConnection(check func(Connection) bool) []Connection
SelectFromConnection gets all connections in the database that satisfy 'check'.
func (Database) SelectFromContainer ¶
SelectFromContainer gets all containers in the database that satisfy 'check'.
func (Database) SelectFromEtcd ¶
SelectFromEtcd gets all Etcd rows in the database that satisfy the 'check'.
func (Database) SelectFromLabel ¶
SelectFromLabel gets all labels in the database that satisfy 'check'.
func (Database) SelectFromMachine ¶
SelectFromMachine gets all machines in the database that satisfy the 'check'.
func (Database) SelectFromMinion ¶
SelectFromMinion gets all minions in the database that satisfy the 'check'.
type Etcd ¶
type Etcd struct { ID int EtcdIPs []string // The set of members in the cluster. Leader bool // True if this Minion is the leader. LeaderIP string // IP address of the current leader, or "" }
The Etcd table contains configuration pertaining to the minion etcd cluster including the members and leadership information.
type LabelSlice ¶
type LabelSlice []Label
LabelSlice is an alias for []Label to allow for joins
func (LabelSlice) Get ¶
func (ls LabelSlice) Get(ii int) interface{}
Get returns the value contained at the given index
type Machine ¶
type Machine struct { ID int //Database ID /* Populated by the policy engine. */ Role Role Provider Provider Region string Size string DiskSize int SSHKeys []string `rowStringer:"omit"` /* Populated by the cloud provider. */ CloudID string //Cloud Provider ID PublicIP string PrivateIP string /* Populated by the foreman. */ Connected bool // Whether the minion on this machine has connected back. }
Machine represents a physical or virtual machine operated by a cloud provider on which containers may be run.
func SortMachines ¶
SortMachines returns a slice of machines sorted according to the default database sort order.
type MachineSlice ¶
type MachineSlice []Machine
MachineSlice is an alias for []Machine to allow for joins
func (MachineSlice) Get ¶
func (ms MachineSlice) Get(ii int) interface{}
Get returns the value contained at the given index
func (MachineSlice) Len ¶
func (ms MachineSlice) Len() int
Len returns the number of items in the slice
type Minion ¶
type Minion struct { ID int `json:"-"` Self bool `json:"-"` Spec string `json:"-"` // Below fields are included in the JSON encoding. Role Role PrivateIP string Provider string Size string Region string }
The Minion table is instantiated on the minions with one row. That row contains the configuration that minion needs to operate, including its ID, Role, and IP address
type MinionSlice ¶
type MinionSlice []Minion
MinionSlice is an alias for []Minion to allow for joins
func (MinionSlice) Get ¶
func (m MinionSlice) Get(ii int) interface{}
Get returns the value contained at the given index
func (MinionSlice) Len ¶
func (m MinionSlice) Len() int
Len returns the number of items in the slice
type Placement ¶
type Placement struct { ID int TargetLabel string Exclusive bool // Label Constraint OtherLabel string // Machine Constraints Provider string Size string Region string }
Placement represents a declaration about how containers should be placed. These directives can be made either relative to labels of other containers, or Machines those containers run on.
type PlacementSlice ¶
type PlacementSlice []Placement
PlacementSlice is an alias for []Placement to allow for joins
func (PlacementSlice) Get ¶
func (ps PlacementSlice) Get(ii int) interface{}
Get returns the value contained at the given index
func (PlacementSlice) Len ¶
func (ps PlacementSlice) Len() int
Len returns the numebr of items in the slice
type Provider ¶
type Provider string
A Provider implements a cloud interface on which machines may be instantiated.
func ParseProvider ¶
ParseProvider returns the Provider represented by 'name' or an error.
type ProviderSlice ¶
type ProviderSlice []Provider
ProviderSlice is an alias for []Provider to allow for joins
func (ProviderSlice) Get ¶
func (ps ProviderSlice) Get(ii int) interface{}
Get returns the value contained at the given index
func (ProviderSlice) Len ¶
func (ps ProviderSlice) Len() int
Len returns the number of items in the slice
type Role ¶
type Role string
The Role a machine may take on within the cluster.
func PBToRole ¶
func PBToRole(p pb.MinionConfig_Role) Role
PBToRole converts a protobuf role to a db.Role.