Documentation ¶
Index ¶
- Constants
- Variables
- func RoleToPB(r Role) pb.MinionConfig_Role
- type ACL
- type Cluster
- type Conn
- func (conn Conn) EtcdLeader() bool
- func (conn Conn) GetClusterNamespace() (namespace string, err error)
- func (conn Conn) MinionSelf() Minion
- func (conn Conn) SelectFromCluster(check func(Cluster) bool) []Cluster
- 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) SelectFromHostname(check func(Hostname) bool) []Hostname
- func (conn Conn) SelectFromLabel(check func(Label) bool) []Label
- func (cn Conn) SelectFromMachine(check func(Machine) bool) []Machine
- func (conn Conn) SelectFromMinion(check func(Minion) bool) []Minion
- func (conn Conn) SelectFromPlacement(check func(Placement) bool) []Placement
- func (cn Conn) Trigger(tt ...TableType) Trigger
- func (cn Conn) TriggerTick(seconds int, tt ...TableType) Trigger
- func (cn Conn) Txn(tables ...TableType) Transaction
- type Connection
- type ConnectionSlice
- type Container
- type ContainerSlice
- type Database
- func (db Database) Commit(r row)
- func (db Database) EtcdLeader() bool
- func (db Database) GetACL() (ACL, error)
- func (db Database) GetCluster() (Cluster, error)
- func (db Database) GetClusterNamespace() (string, error)
- func (db Database) GetEtcd() (Etcd, error)
- func (db Database) InsertACL() ACL
- func (db Database) InsertCluster() Cluster
- func (db Database) InsertConnection() Connection
- func (db Database) InsertContainer() Container
- func (db Database) InsertEtcd() Etcd
- func (db Database) InsertHostname() Hostname
- func (db Database) InsertImage() Image
- 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
- func (db Database) Remove(r row)
- func (db Database) SelectFromACL(check func(ACL) bool) []ACL
- 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) SelectFromHostname(check func(Hostname) bool) []Hostname
- func (db Database) SelectFromImage(check func(Image) bool) []Image
- 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 Hostname
- type HostnameSlice
- type Image
- type ImageSlice
- type Label
- type LabelSlice
- type Machine
- type MachineSlice
- type Minion
- type MinionSlice
- type Placement
- type PlacementSlice
- type PortRange
- type Provider
- type ProviderSlice
- type Role
- type TableType
- type Transaction
- 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" // DigitalOcean implements Digital Ocean Droplets. DigitalOcean = "DigitalOcean" // Vagrant implements local virtual machines. Vagrant = "Vagrant" )
Variables ¶
var ACLTable = TableType(reflect.TypeOf(ACL{}).String())
ACLTable is the type of the ACL table.
var AllTables = []TableType{ClusterTable, MachineTable, ContainerTable, MinionTable, ConnectionTable, LabelTable, EtcdTable, PlacementTable, ACLTable, ImageTable, HostnameTable}
AllTables is a slice of all the db TableTypes. It is used primarily for tests, where there is no reason to put lots of thought into which tables a Transaction should use.
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 HostnameTable = TableType(reflect.TypeOf(Hostname{}).String())
HostnameTable is the type of the Hostname table.
var ImageTable = TableType(reflect.TypeOf(Image{}).String())
ImageTable is the type of the image 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 `rowStringer:"omit"` }
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 created.
func (Conn) EtcdLeader ¶
EtcdLeader returns true if the minion is the lead master for the cluster.
func (Conn) GetClusterNamespace ¶
GetClusterNamespace returns the namespace of the single cluster object in the cluster table. Otherwise it returns an error.
func (Conn) MinionSelf ¶
MinionSelf returns the Minion Row corresponding to the currently running minion. If there is no Minion Row, it panics
func (Conn) SelectFromCluster ¶
SelectFromCluster gets all clusters in the database that satisfy 'check'.
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) SelectFromHostname ¶
SelectFromHostname gets all hostnames in the database that satisfy the 'check'.
func (Conn) SelectFromLabel ¶
SelectFromLabel gets all labels in the database connection that satisfy 'check'.
func (Conn) SelectFromMachine ¶
SelectFromMachine gets all machines in the database 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) Trigger ¶
Trigger registers a new database trigger that watches changes to 'tableName'. Any change to the table, including row insertions, deletions, and modifications, will cause a notification on 'Trigger.C'.
func (Conn) TriggerTick ¶
TriggerTick creates a trigger, similar to Trigger(), that additionally ticks once every N 'seconds'. So that clients properly initialize, TriggerTick() sends an initialization tick at startup.
func (Conn) Txn ¶
func (cn Conn) Txn(tables ...TableType) Transaction
Txn creates a new Transaction object connected to the same database, but with restricted access to only the given tables.
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(i 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.
func (ConnectionSlice) Less ¶
func (cs ConnectionSlice) Less(i, j int) bool
Less implements less than for sort.Interface.
func (ConnectionSlice) Swap ¶
func (cs ConnectionSlice) Swap(i, j int)
Swap implements swapping for sort.Interface.
type Container ¶
type Container struct { ID int `json:"-"` IP string `json:",omitempty"` Minion string `json:",omitempty"` EndpointID string `json:",omitempty"` StitchID string `json:",omitempty"` DockerID string `json:",omitempty"` Status string `json:",omitempty"` Command []string `json:",omitempty"` Labels []string `json:",omitempty"` Env map[string]string `json:",omitempty"` FilepathToContent map[string]string `json:",omitempty"` Hostname string `json:"-"` Created time.Time `json:","` Image string `json:",omitempty"` ImageID string `json:",omitempty"` Dockerfile string `json:"-"` }
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
func (ContainerSlice) Less ¶
func (cs ContainerSlice) Less(i, j int) bool
Less implements less than for sort.Interface.
func (ContainerSlice) Swap ¶
func (cs ContainerSlice) Swap(i, j int)
Swap implements swapping for sort.Interface.
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) GetACL ¶
GetACL gets the ACL row from the database. There should only ever be a single ACL row.
func (Database) GetCluster ¶
GetCluster gets the cluster from the database. There should only ever be a single cluster.
func (Database) GetClusterNamespace ¶
GetClusterNamespace returns the namespace of the single cluster object in the cluster table. Otherwise it returns an error.
func (Database) GetEtcd ¶
GetEtcd gets the Etcd row from the database. There should only ever be a single Etcd row.
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) InsertHostname ¶
InsertHostname creates a new Hostname row and inserts it into 'db'.
func (Database) InsertImage ¶
InsertImage creates a new image 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. If there is no Minion Row, it panics
func (Database) SelectFromACL ¶
SelectFromACL gets all acls in the database that satisfy 'check'.
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) SelectFromHostname ¶
SelectFromHostname gets all hostnames in the database that satisfy 'check'.
func (Database) SelectFromImage ¶
SelectFromImage gets all images in the database that satisfy '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 HostnameSlice ¶
type HostnameSlice []Hostname
HostnameSlice is an alias for []Hostname to allow for joins
func (HostnameSlice) Get ¶
func (hs HostnameSlice) Get(i int) interface{}
Get returns the value contained at the given index
func (HostnameSlice) Len ¶
func (hs HostnameSlice) Len() int
Len returns the number of items in the slice
func (HostnameSlice) Less ¶
func (hs HostnameSlice) Less(i, j int) bool
Less implements less than for sort.Interface.
func (HostnameSlice) Swap ¶
func (hs HostnameSlice) Swap(i, j int)
Swap implements swapping for sort.Interface.
type Image ¶
type Image struct { ID int // The desired name for the image. Name string // The Dockerfile with which to build the image. Dockerfile string // The ID of the built image. DockerID string }
An Image row represents a Docker image that should be built by the Quilt masters.
type ImageSlice ¶
type ImageSlice []Image
ImageSlice is an alias for []Image to allow for joins
func (ImageSlice) Get ¶
func (slc ImageSlice) Get(ii int) interface{}
Get returns the value contained at the given index
func (ImageSlice) Len ¶
func (slc ImageSlice) Len() int
Len returns the number of items in the slice.
type LabelSlice ¶
type LabelSlice []Label
LabelSlice is an alias for []Label to allow for joins
func (LabelSlice) Get ¶
func (ls LabelSlice) Get(i int) interface{}
Get returns the value contained at the given index
func (LabelSlice) Less ¶
func (ls LabelSlice) Less(i, j int) bool
Less implements less than for sort.Interface.
func (LabelSlice) Swap ¶
func (ls LabelSlice) Swap(i, j int)
Swap implements swapping for sort.Interface.
type Machine ¶
type Machine struct { ID int //Database ID /* Populated by the policy engine. */ StitchID string Role Role Provider Provider Region string Size string DiskSize int SSHKeys []string `rowStringer:"omit"` FloatingIP string Preemptible bool /* 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:"-" rowStringer:"omit"` AuthorizedKeys string `json:"-" rowStringer:"omit"` // Below fields are included in the JSON encoding. Role Role PrivateIP string Provider string Size string Region string FloatingIP 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 FloatingIP 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.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
A Transaction is a database handle on which transactions may be executed.
func (Transaction) Run ¶
func (tr Transaction) Run(do func(db Database) error) error
Run executes database transactions. It takes a closure, 'do', which is operates on its 'db' argument. Transactions may be concurrent, but only if they operate on independent sets of tables. Otherwise, each transaction runs sequentially on it's database without conflicting with other transactions.