Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container interface {
// Start starts the container if not running already
Start() error
// Stop stopps the container if running
Stop() error
// Exec executes a command on the container
Exec(cmd string) error
// Stats returns the last stats obtained from the container
Stats() (ContainerStats, error)
// StatsChan returns a channel that receives the container stats
StatsChan() (<-chan *ContainerStats, error)
// Status says whether the server is running or not
Status() Status
// Logger returns the logger used by the server
// logs sent here, will be redirected to the container stdout
Logger() *logrus.Entry
}
Container represents the container the server is running on.
type ContainerBind ¶
type ContainerBind struct {
// HostDir defines where to bind the volume on the host machine.
HostDir string `hcl:"host_dir" json:"host_dir,omitempty"`
// Volume defines the volume to be binded.
Volume string `hcl:"volume,optional" json:"volume"`
}
ContainerBind defines which volume binds to use.
type ContainerImage ¶
type ContainerImage struct {
ID string `hcl:"id" json:"id"`
}
type ContainerMemory ¶
type ContainerNetwork ¶
type ContainerNetwork struct {
Binds []ContainerNetworkBind `hcl:"bind,block" json:"expose"`
}
type ContainerNetworkBind ¶
type ContainerOptions ¶
type ContainerOptions struct {
ContainerName string `json:"container_name,omitempty"`
Binds []ContainerBind
Image ContainerImage `json:"container_image"`
Memory ContainerMemory `json:"memory"`
Network *ContainerNetwork `json:"network,omitempty"`
}
ContainerOptions holds the options used to create a new container
type ContainerOpts ¶
type ContainerOpts func(*ContainerOptions)
ContainerOpts helps you to easily model the container options according to your needs.
func WithPreset ¶
func WithPreset(preset ServerPreset) ContainerOpts
type ContainerStats ¶
type ContainerStats struct {
// Percentage of CPU usage, sum of all cores
CPUPercentage float64 `json:"cpu_percentage"`
// Percentage of RAM usage
MemoryPercentage float64 `json:"memory_percentage"`
// RAM usage in bytes
Memory uint64 `json:"memory"`
// Max available RAM in bytes
MemoryLimit uint64 `json:"memory_limit"`
// Total network download bytes, since start
NetworkDownload uint64 `json:"network_download"`
// Total network upload bytes, since start
NetworkUpload uint64 `json:"network_upload"`
// Disc read
// TODO investigate meaning of returned values
DiscRead uint64 `json:"disc_read"`
// Disc write
DiscWrite uint64 `json:"disc_write"`
}
ContainerStats holds the stats relative to a container at a point in time.
type ServerCreateOptions ¶
type ServerCreateOptions struct {
ServerID string `hcl:"server_id"`
ServerName string `hcl:"server_name"`
// Binds defines which volume binds to use.
Binds []ContainerBind `hcl:"bind,block"`
ContainerImage *ContainerImage `hcl:"container_image,block"`
Memory *ContainerMemory `hcl:"memory,block"`
Network *ContainerNetwork `hcl:"network,block"`
}
ServerCreateOptions holds information needed to create a new Server
type ServerPreset ¶
type ServerPreset ServerCreateOptions
ServerPreset represents a preset to be used for Server creation
type Status ¶
type Status string
Status represents whether the server is running or not.
const ( // StatusRunning indicates the server is running. StatusRunning Status = "running" // StatusStopped indicates the server is stopped. StatusStopped Status = "stopped" // StatusStarting indicates the server is still starting and not yet running. // This option can be omitted and passed directly to running if // the server software in use is not supported. StatusStarting Status = "starting" // StatusStopping indicates the server is stopping, but not yet stopped. StatusStopping Status = "stopping" )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.