Documentation ¶
Index ¶
- Variables
- func SortedIPs(ips []string) []string
- type BackoffTimer
- type Config
- type ContainerInfo
- type ContainerMetrics
- type Description
- type ExecConnection
- type FirewallConfig
- type GPUConfig
- type HubConfig
- type LocatorConfig
- type LoggingConfig
- type Miner
- func (m *Miner) Close()
- func (m *Miner) DiscoverHub(ctx context.Context, request *pb.DiscoverHubRequest) (*pb.Empty, error)
- func (m *Miner) GetContainerInfo(id string) (*ContainerInfo, bool)
- func (m *Miner) Handshake(ctx context.Context, request *pb.MinerHandshakeRequest) (*pb.MinerHandshakeReply, error)
- func (m *Miner) Info(ctx context.Context, request *pb.Empty) (*pb.InfoReply, error)
- func (m *Miner) Load(stream pb.Miner_LoadServer) error
- func (m *Miner) Ping(ctx context.Context, _ *pb.Empty) (*pb.PingReply, error)
- func (m *Miner) Save(request *pb.SaveRequest, stream pb.Miner_SaveServer) error
- func (m *Miner) Serve() error
- func (m *Miner) Start(ctx context.Context, request *pb.MinerStartRequest) (*pb.MinerStartReply, error)
- func (m *Miner) Stop(ctx context.Context, request *pb.ID) (*pb.Empty, error)
- func (m *Miner) TaskDetails(ctx context.Context, req *pb.ID) (*pb.TaskStatusReply, error)
- func (m *Miner) TaskLogs(request *pb.TaskLogsRequest, server pb.Miner_TaskLogsServer) error
- func (m *Miner) TasksStatus(server pb.Miner_TasksStatusServer) error
- type MinerBuilder
- func (b *MinerBuilder) Build() (miner *Miner, err error)
- func (b *MinerBuilder) Config(config Config) *MinerBuilder
- func (b *MinerBuilder) Context(ctx context.Context) *MinerBuilder
- func (b *MinerBuilder) Hardware(hardware hardware.HardwareInfo) *MinerBuilder
- func (b *MinerBuilder) Overseer(ovs Overseer) *MinerBuilder
- func (b *MinerBuilder) SSH(ssh SSH) *MinerBuilder
- func (b *MinerBuilder) UUID(uuid string) *MinerBuilder
- type Overseer
- type Resources
- type ResourcesConfig
- type SSH
- type SSHConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrListenerClosed is returned to clients and servers is the listener closed ErrListenerClosed = errors.New("inmemory listener closed") )
Functions ¶
Types ¶
type BackoffTimer ¶
type BackoffTimer struct {
// contains filtered or unexported fields
}
BackoffTimer implementation
func NewBackoffTimer ¶
func NewBackoffTimer(sleep, maxsleep time.Duration) *BackoffTimer
NewBackoffTimer implementations one direction backoff policy
func (*BackoffTimer) C ¶
func (b *BackoffTimer) C() <-chan time.Time
C resets Timer and returns Timer.C
type Config ¶ added in v0.3.0
type Config interface { // HubEndpoint returns a string representation of a Hub endpoint to communicate with. HubEndpoint() string // HubResources returns resources allocated for a Hub. HubResources() *ResourcesConfig // Firewall returns firewall detection settings. Firewall() *FirewallConfig // PublicIPs returns all IPs that can be used to communicate with the miner. PublicIPs() []string // GPU returns options about NVIDIA GPU support via nvidia-docker-plugin GPU() *gpu.Config // SSH returns settings for built-in ssh server SSH() *SSHConfig // Logging returns logging settings. Logging() LoggingConfig // Path to store Miner uuid UUIDPath() string // ETH returns ethereum configuration ETH() *accounts.EthConfig // LocatorEndpoint returns locator endpoint. LocatorEndpoint() string }
Config represents a Miner configuration interface.
type ContainerInfo ¶
type ContainerInfo struct { ID string ImageName string StartAt time.Time Ports nat.PortMap Resources resource.Resources PublicKey ssh.PublicKey Cgroup string CgroupParent string // contains filtered or unexported fields }
ContainerInfo is a brief information about containers
type ContainerMetrics ¶
type ContainerMetrics struct {
// contains filtered or unexported fields
}
ContainerMetrics are metrics collected from Docker about running containers
func (*ContainerMetrics) Marshal ¶ added in v0.3.0
func (m *ContainerMetrics) Marshal() *pb.ResourceUsage
type Description ¶
type Description struct { Registry string Image string Auth string RestartPolicy container.RestartPolicy Resources container.Resources Cmd []string Env map[string]string TaskId string DealId string CommitOnStop bool GPURequired bool }
Description for a target application.
func (*Description) FormatEnv ¶ added in v0.3.0
func (d *Description) FormatEnv() []string
type ExecConnection ¶ added in v0.3.0
type ExecConnection types.HijackedResponse
type FirewallConfig ¶ added in v0.3.0
type FirewallConfig struct { // STUN server endpoint (with port). Server string `yaml:"server"` }
FirewallConfig describes firewall detection settings.
type GPUConfig ¶ added in v0.3.0
type GPUConfig struct {
NvidiaDockerDriver string `yaml:"nvidiadockerdriver"`
}
GPUConfig contains options related to NVIDIA GPU support
type HubConfig ¶ added in v0.3.0
type HubConfig struct { Endpoint string `required:"true" yaml:"endpoint"` CGroups *ResourcesConfig `required:"false" yaml:"resources"` }
HubConfig describes Hub configuration.
type LocatorConfig ¶ added in v0.3.0
type LocatorConfig struct {
Endpoint string `required:"true" yaml:"endpoint"`
}
type LoggingConfig ¶ added in v0.3.0
type LoggingConfig struct {
Level int `required:"true" default:"1"`
}
type Miner ¶
type Miner struct {
// contains filtered or unexported fields
}
Miner holds information about jobs, make orders to Observer and communicates with Hub
func (*Miner) DiscoverHub ¶ added in v0.3.0
func (*Miner) GetContainerInfo ¶ added in v0.3.0
func (m *Miner) GetContainerInfo(id string) (*ContainerInfo, bool)
func (*Miner) Handshake ¶
func (m *Miner) Handshake(ctx context.Context, request *pb.MinerHandshakeRequest) (*pb.MinerHandshakeReply, error)
Handshake is the first frame received from a Hub.
This is a self representation about initial resources this Miner provides. TODO: May be useful to register a channel to cover runtime resource changes.
func (*Miner) Info ¶
Info returns runtime statistics collected from all containers working on this miner.
This works the following way: a miner periodically collects various runtime statistics from all spawned containers that it knows about. For running containers metrics map the immediate state, for dead containers - their last memento.
func (*Miner) Save ¶ added in v0.3.0
func (m *Miner) Save(request *pb.SaveRequest, stream pb.Miner_SaveServer) error
func (*Miner) Start ¶
func (m *Miner) Start(ctx context.Context, request *pb.MinerStartRequest) (*pb.MinerStartReply, error)
Start request from Hub makes Miner start a container
func (*Miner) TaskDetails ¶ added in v0.3.0
func (*Miner) TaskLogs ¶ added in v0.3.0
func (m *Miner) TaskLogs(request *pb.TaskLogsRequest, server pb.Miner_TaskLogsServer) error
TaskLogs returns logs from container
func (*Miner) TasksStatus ¶
func (m *Miner) TasksStatus(server pb.Miner_TasksStatusServer) error
TasksStatus returns the status of a task
type MinerBuilder ¶ added in v0.3.0
type MinerBuilder struct {
// contains filtered or unexported fields
}
func NewMinerBuilder ¶ added in v0.3.0
func NewMinerBuilder(cfg Config, key *ecdsa.PrivateKey) (*MinerBuilder, error)
func (*MinerBuilder) Build ¶ added in v0.3.0
func (b *MinerBuilder) Build() (miner *Miner, err error)
func (*MinerBuilder) Config ¶ added in v0.3.0
func (b *MinerBuilder) Config(config Config) *MinerBuilder
func (*MinerBuilder) Context ¶ added in v0.3.0
func (b *MinerBuilder) Context(ctx context.Context) *MinerBuilder
func (*MinerBuilder) Hardware ¶ added in v0.3.0
func (b *MinerBuilder) Hardware(hardware hardware.HardwareInfo) *MinerBuilder
func (*MinerBuilder) Overseer ¶ added in v0.3.0
func (b *MinerBuilder) Overseer(ovs Overseer) *MinerBuilder
func (*MinerBuilder) SSH ¶ added in v0.3.0
func (b *MinerBuilder) SSH(ssh SSH) *MinerBuilder
func (*MinerBuilder) UUID ¶ added in v0.3.0
func (b *MinerBuilder) UUID(uuid string) *MinerBuilder
type Overseer ¶
type Overseer interface { // Load loads an image from the specified reader to the Docker. Load(ctx context.Context, rd io.Reader) (imageLoadStatus, error) // Save saves an image from the Docker into the returned reader. Save(ctx context.Context, imageID string) (types.ImageInspect, io.ReadCloser, error) // Spool prepares an application for its further start. // // For Docker containers this is an equivalent of pulling from the registry. Spool(ctx context.Context, d Description) error // Start attempts to start an application using the specified description. // // After successful starting an application becomes a target for accepting request, but not guarantees // to complete them. Start(ctx context.Context, description Description) (chan pb.TaskStatusReply_Status, ContainerInfo, error) // Exec a given command in running container Exec(ctx context.Context, Id string, cmd []string, env []string, isTty bool, wCh <-chan ssh.Window) (types.HijackedResponse, error) // Stop terminates the container. Stop(ctx context.Context, containerID string) error // Returns runtime statistics collected from all running containers. // // Depending on the implementation this can be cached. Info(ctx context.Context) (map[string]ContainerMetrics, error) // Fetch logs of the container Logs(ctx context.Context, id string, opts types.ContainerLogsOptions) (io.ReadCloser, error) // Close terminates all associated asynchronous operations and prepares the Overseer for shutting down. Close() error }
Overseer watches all miner's applications.
type Resources ¶ added in v0.3.0
type Resources specs.LinuxResources
CGroups is a type alias for OCI CGroups spec
type ResourcesConfig ¶ added in v0.3.0
type ResourcesConfig struct { Cgroup string `required:"true" yaml:"cgroup"` Resources *specs.LinuxResources `required:"false" yaml:"resources"` }