Documentation
¶
Index ¶
- Variables
- func SortedIPs(ips []string) []string
- type BackoffTimer
- type Config
- type ContainerInfo
- type ContainerMetrics
- type Description
- type ExecConnection
- type FirewallConfig
- 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 Option
- func WithContext(ctx context.Context) Option
- func WithHardware(hardwareInfo hardware.HardwareInfo) Option
- func WithKey(key *ecdsa.PrivateKey) Option
- func WithLocatorClient(locatorClient pb.LocatorClient) Option
- func WithNat(nat stun.NATType) Option
- func WithOverseer(ovs Overseer) Option
- func WithSSH(ssh SSH) Option
- func WithUUID(uuid string) Option
- 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 { // HubEndpoints returns a string representation of a Hub endpoint to communicate with. HubEndpoints() []string // HubEthAddr returns hub's ethereum address. HubEthAddr() string // HubResolveEndpoints returns `true` if we need to resolve hub's endpoints via locator. HubResolveEndpoints() bool // 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 // 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 // MetricsListenAddr returns the address that can be used by Prometheus to get // metrics. MetricsListenAddr() string // Plugins returns plugins settings. Plugins() plugin.Config }
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 // contains filtered or unexported fields }
Description for a target application.
func (*Description) FormatEnv ¶ added in v0.3.0
func (d *Description) FormatEnv() []string
func (*Description) GPU ¶ added in v0.3.2
func (d *Description) GPU() bool
func (*Description) ID ¶ added in v0.3.2
func (d *Description) ID() 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 HubConfig ¶ added in v0.3.0
type HubConfig struct { EthAddr string `required:"true" yaml:"eth_addr"` ResolveEndpoints bool `required:"false" yaml:"resolve_endpoints"` Endpoints []string `required:"false" yaml:"endpoints"` 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 Option ¶ added in v0.3.2
type Option func(*options)
func WithContext ¶ added in v0.3.2
func WithHardware ¶ added in v0.3.2
func WithHardware(hardwareInfo hardware.HardwareInfo) Option
func WithKey ¶ added in v0.3.2
func WithKey(key *ecdsa.PrivateKey) Option
func WithLocatorClient ¶ added in v0.3.2
func WithLocatorClient(locatorClient pb.LocatorClient) Option
func WithOverseer ¶ added in v0.3.2
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 // Info 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.
func NewOverseer ¶
NewOverseer creates new overseer
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"` }