Documentation ¶
Index ¶
- Variables
- type ACLStorage
- type AllocationStatus
- type Cluster
- type ClusterConfig
- type ClusterEvent
- type Config
- type DealID
- type DealMeta
- type DealMetaData
- type DeviceProperties
- type ETH
- type EventAuthorization
- type GatewayConfig
- type Hub
- func (h *Hub) Close()
- func (h *Hub) DeregisterWorker(ctx context.Context, request *pb.ID) (*pb.Empty, error)
- func (h *Hub) Devices(ctx context.Context, request *pb.Empty) (*pb.DevicesReply, error)
- func (h *Hub) DiscoverHub(ctx context.Context, request *pb.DiscoverHubRequest) (*pb.Empty, error)
- func (h *Hub) GetDealInfo(ctx context.Context, dealID *pb.ID) (*pb.DealInfoReply, error)
- func (h *Hub) GetDeviceProperties(ctx context.Context, request *pb.ID) (*pb.GetDevicePropertiesReply, error)
- func (h *Hub) GetRegisteredWorkers(ctx context.Context, empty *pb.Empty) (*pb.GetRegisteredWorkersReply, error)
- func (h *Hub) Info(ctx context.Context, request *pb.ID) (*pb.InfoReply, error)
- func (h *Hub) InsertSlot(ctx context.Context, request *pb.InsertSlotRequest) (*pb.ID, error)
- func (h *Hub) List(ctx context.Context, request *pb.Empty) (*pb.ListReply, error)
- func (h *Hub) MinerDevices(ctx context.Context, request *pb.ID) (*pb.DevicesReply, error)
- func (h *Hub) MinerStatus(ctx context.Context, request *pb.ID) (*pb.StatusMapReply, error)
- func (h *Hub) Ping(ctx context.Context, _ *pb.Empty) (*pb.PingReply, error)
- func (h *Hub) ProposeDeal(ctx context.Context, r *pb.DealRequest) (*pb.Empty, error)
- func (h *Hub) PullTask(request *pb.PullTaskRequest, stream pb.Hub_PullTaskServer) error
- func (h *Hub) PushTask(stream pb.Hub_PushTaskServer) error
- func (h *Hub) RegisterWorker(ctx context.Context, request *pb.ID) (*pb.Empty, error)
- func (h *Hub) RemoveSlot(ctx context.Context, request *pb.ID) (*pb.Empty, error)
- func (h *Hub) Serve() error
- func (h *Hub) SetDeviceProperties(ctx context.Context, request *pb.SetDevicePropertiesRequest) (*pb.Empty, error)
- func (h *Hub) Slots(ctx context.Context, request *pb.Empty) (*pb.SlotsReply, error)
- func (h *Hub) StartTask(ctx context.Context, request *pb.HubStartTaskRequest) (*pb.HubStartTaskReply, error)
- func (h *Hub) Status(ctx context.Context, _ *pb.Empty) (*pb.HubStatusReply, error)
- func (h *Hub) StopTask(ctx context.Context, request *pb.ID) (*pb.Empty, error)
- func (h *Hub) TaskList(ctx context.Context, request *pb.Empty) (*pb.TaskListReply, error)
- func (h *Hub) TaskLogs(request *pb.TaskLogsRequest, server pb.Hub_TaskLogsServer) error
- func (h *Hub) TaskStatus(ctx context.Context, request *pb.ID) (*pb.TaskStatusReply, error)
- type LeadershipEvent
- type LocatorConfig
- type LoggingConfig
- type Market
- type MarketConfig
- type MinerCtx
- func (m *MinerCtx) Close()
- func (m *MinerCtx) Consume(Id OrderID, usage *resource.Resources) error
- func (m *MinerCtx) ID() string
- func (m *MinerCtx) OrderUsage(id OrderID) (*resource.Resources, error)
- func (m *MinerCtx) Orders() []OrderID
- func (m *MinerCtx) PollConsume(usage *resource.Resources) error
- func (m *MinerCtx) Release(id OrderID)
- type NewMemberEvent
- type Option
- func WithBlockchain(bcr blockchain.Blockchainer) Option
- func WithCertRotator(rot util.HitlessCertRotator) Option
- func WithCluster(cl Cluster, evt <-chan ClusterEvent) Option
- func WithContext(ctx context.Context) Option
- func WithCreds(creds credentials.TransportCredentials) Option
- func WithLocator(loc pb.LocatorClient) Option
- func WithMarket(mp pb.MarketClient) Option
- func WithPrivateKey(k *ecdsa.PrivateKey) Option
- func WithVersion(v string) Option
- type OrderID
- type Scheduler
- type StoreConfig
- type TaskInfo
- type Whitelist
- type WhitelistConfig
- type WhitelistRecord
Constants ¶
This section is empty.
Variables ¶
var (
ErrMinerNotFound = status.Errorf(codes.NotFound, "miner not found")
)
Functions ¶
This section is empty.
Types ¶
type ACLStorage ¶ added in v0.3.0
type ACLStorage interface { // Insert inserts the given worker credentials to the storage. Insert(credentials string) // Remove removes the given worker credentials from the storage. // Returns true if it was actually removed. Remove(credentials string) bool // Has checks whether the given worker credentials contains in the // storage. Has(credentials string) bool // Each applies the specified function to each credentials in the storage. // Traversal will continue until all items in the Set have been visited, // or if the closure returns false. Each(fn func(string) bool) }
ACLStorage describes an ACL storage for workers.
A worker connection can be accepted only and the only if its credentials provided with the certificate contains in this storage.
func NewACLStorage ¶ added in v0.3.0
func NewACLStorage() ACLStorage
type AllocationStatus ¶ added in v0.3.0
type AllocationStatus int
const ( FREE AllocationStatus = iota RESERVED ALLOCATED )
type Cluster ¶ added in v0.3.0
type Cluster interface { // Starts synchronization process. Can be called multiple times after error is received in EventChannel Run() error Close() // IsLeader returns true if this cluster is a leader, i.e. we rule the // synchronization process. IsLeader() bool LeaderClient() (pb.HubClient, error) RegisterAndLoadEntity(name string, prototype interface{}) error Synchronize(entity interface{}) error // Fetch current cluster members Members() ([]NewMemberEvent, error) }
func NewCluster ¶ added in v0.3.0
func NewCluster(ctx context.Context, cfg *ClusterConfig, creds credentials.TransportCredentials) (Cluster, <-chan ClusterEvent, error)
Returns a cluster writer interface if this node is a master, event channel otherwise. Should be recalled when a cluster's master/slave state changes. The channel is closed when the specified context is canceled.
type ClusterConfig ¶ added in v0.3.0
type ClusterConfig struct { Store StoreConfig `yaml:"store"` Failover bool `yaml:"failover"` Endpoint string `yaml:"endpoint"` AnnounceEndpoint string `yaml:"announce_endpoint"` LeaderKey string `yaml:"leader_key" default:"sonm/hub/leader"` MemberListKey string `yaml:"member_list_key" default:"sonm/hub/list"` SynchronizableEntitiesPrefix string `yaml:"sync_prefix" default:"sonm/hub/sync"` LeaderTTL uint64 `yaml:"leader_ttl" default:"20"` AnnouncePeriod uint64 `yaml:"announce_period" default:"10"` AnnounceTTL uint64 `yaml:"announce_ttl" default:"20"` MemberGCPeriod uint64 `yaml:"member_gc_period" default:"60"` }
type ClusterEvent ¶ added in v0.3.0
type ClusterEvent interface{}
type Config ¶ added in v0.3.0
type Config struct { Endpoint string `required:"true" yaml:"endpoint"` GatewayConfig *GatewayConfig `yaml:"gateway"` Logging LoggingConfig `yaml:"logging"` Eth accounts.EthConfig `yaml:"ethereum"` Locator LocatorConfig `yaml:"locator"` Market MarketConfig `yaml:"market"` Cluster ClusterConfig `yaml:"cluster"` Whitelist WhitelistConfig `yaml:"whitelist"` }
func (*Config) EndpointIP ¶ added in v0.3.0
type DealMetaData ¶ added in v0.3.0
type DealMetaData interface { // Deal extracts deal ID from the request. Deal(ctx context.Context, request interface{}) (DealID, error) // Wallet extracts self-signed wallet from the request. Wallet(ctx context.Context, request interface{}) (string, error) }
DealMetaData allows to extract deal-specific parameters for authorization. We implement this interface for all methods that require wallet authorization.
type DeviceProperties ¶ added in v0.3.0
type ETH ¶ added in v0.3.0
type ETH interface { // VerifyBuyerBalance verifies that the buyer specified under the given // order has enough balance to have a deal. VerifyBuyerBalance(bidOrder *structs.Order) error // VerifyBuyerAllowance verifies that the buyer specified under the given // order has enough allowance to have a deal. VerifyBuyerAllowance(bidOrder *structs.Order) error // GetAcceptedDeals returns all currently accepted deals. GetAcceptedDeals(ctx context.Context) ([]*pb.Deal, error) // GetClosedDeals returns all currently closed deals. // Warning: use with caution: this may return significantly large amount // of data. GetClosedDeals(ctx context.Context) ([]*pb.Deal, error) // WaitForDealCreated waits for deal created on Buyer-side WaitForDealCreated(request *structs.DealRequest, buyerID string) (*pb.Deal, error) // WaitForDealClosed blocks the current execution context until the // specified deal is closed. WaitForDealClosed(ctx context.Context, dealID DealID, buyerID string) error // AcceptDeal approves deal on Hub-side. AcceptDeal(id string) error // CloseDeal closes the specified deal on Hub-side. CloseDeal(id DealID) error // GetDeal checks whether a given deal exists. GetDeal(id string) (*pb.Deal, error) }
func NewETH ¶ added in v0.3.0
func NewETH(ctx context.Context, key *ecdsa.PrivateKey, bcr blockchain.Blockchainer, timeout time.Duration) (ETH, error)
NewETH constructs a new Ethereum client.
type EventAuthorization ¶ added in v0.3.0
type GatewayConfig ¶ added in v0.3.0
type GatewayConfig struct {
Ports []uint16 `required:"true" yaml:"ports"`
}
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub collects miners, send them orders to spawn containers, etc.
func (*Hub) DeregisterWorker ¶ added in v0.3.0
DeregisterWorkers deny Worker with given ID to connect to the Hub
func (*Hub) DiscoverHub ¶ added in v0.3.0
func (*Hub) GetDealInfo ¶ added in v0.3.0
func (*Hub) GetDeviceProperties ¶ added in v0.3.0
func (*Hub) GetRegisteredWorkers ¶ added in v0.3.0
func (h *Hub) GetRegisteredWorkers(ctx context.Context, empty *pb.Empty) (*pb.GetRegisteredWorkersReply, error)
GetRegisteredWorkers returns a list of Worker IDs that are allowed to connect to the Hub.
func (*Hub) InsertSlot ¶ added in v0.3.0
func (*Hub) MinerDevices ¶ added in v0.3.0
func (*Hub) MinerStatus ¶
func (*Hub) ProposeDeal ¶ added in v0.3.0
func (*Hub) PullTask ¶ added in v0.3.0
func (h *Hub) PullTask(request *pb.PullTaskRequest, stream pb.Hub_PullTaskServer) error
func (*Hub) RegisterWorker ¶ added in v0.3.0
RegisterWorker allows Worker with given ID to connect to the Hub
func (*Hub) RemoveSlot ¶ added in v0.3.0
func (*Hub) SetDeviceProperties ¶ added in v0.3.0
func (*Hub) StartTask ¶
func (h *Hub) StartTask(ctx context.Context, request *pb.HubStartTaskRequest) (*pb.HubStartTaskReply, error)
func (*Hub) TaskLogs ¶ added in v0.3.0
func (h *Hub) TaskLogs(request *pb.TaskLogsRequest, server pb.Hub_TaskLogsServer) error
func (*Hub) TaskStatus ¶
type LeadershipEvent ¶ added in v0.3.0
Specific type of cluster event emited when leadership is transferred. It is not always loss or aquire of leadership of this specific node
type LocatorConfig ¶ added in v0.3.0
type LoggingConfig ¶ added in v0.3.0
type LoggingConfig struct {
Level int `required:"true" default:"1"`
}
type Market ¶ added in v0.3.0
type Market interface { // OrderExists checks whether an order with the specified ID exists in the // marketplace. OrderExists(ID string) (bool, error) // CreateOrder creates order on marketplace CreateOrder(ord *pb.Order) (*pb.Order, error) // CancelOrder removes order from marketplace CancelOrder(ID string) error }
type MarketConfig ¶ added in v0.3.0
type MarketConfig struct {
Endpoint string `required:"true" yaml:"endpoint"`
}
type MinerCtx ¶
type MinerCtx struct { // gRPC Client Client pb.MinerClient // contains filtered or unexported fields }
MinerCtx holds all the data related to a connected Miner
func (*MinerCtx) OrderUsage ¶ added in v0.3.0
func (*MinerCtx) Orders ¶ added in v0.3.0
Orders returns a list of allocated orders. Useful for looking for a proper miner for starting tasks.
func (*MinerCtx) PollConsume ¶ added in v0.3.0
type NewMemberEvent ¶ added in v0.3.0
type NewMemberEvent struct { Id string // contains filtered or unexported fields }
Specific type of cluster event emited when new member joins cluster
type Option ¶ added in v0.3.0
type Option func(options *options)
Option func is for applying any params to hub options
func WithBlockchain ¶ added in v0.3.0
func WithBlockchain(bcr blockchain.Blockchainer) Option
func WithCertRotator ¶ added in v0.3.0
func WithCertRotator(rot util.HitlessCertRotator) Option
func WithCluster ¶ added in v0.3.0
func WithCluster(cl Cluster, evt <-chan ClusterEvent) Option
func WithContext ¶ added in v0.3.0
func WithCreds ¶ added in v0.3.0
func WithCreds(creds credentials.TransportCredentials) Option
func WithLocator ¶ added in v0.3.0
func WithLocator(loc pb.LocatorClient) Option
func WithMarket ¶ added in v0.3.0
func WithMarket(mp pb.MarketClient) Option
func WithPrivateKey ¶ added in v0.3.0
func WithPrivateKey(k *ecdsa.PrivateKey) Option
func WithVersion ¶ added in v0.3.0
type Scheduler ¶ added in v0.3.0
type Scheduler struct {
// contains filtered or unexported fields
}
type StoreConfig ¶ added in v0.3.0
type TaskInfo ¶ added in v0.3.0
type TaskInfo struct { structs.StartTaskRequest pb.MinerStartReply ID string DealId DealID MinerId string EndTime *time.Time }
type Whitelist ¶ added in v0.3.0
type Whitelist interface {
Allowed(ctx context.Context, registry string, image string, auth string) (bool, reference.Named, error)
}
func NewWhitelist ¶ added in v0.3.0
func NewWhitelist(ctx context.Context, config *WhitelistConfig) Whitelist
type WhitelistConfig ¶ added in v0.3.0
type WhitelistRecord ¶ added in v0.3.0
type WhitelistRecord struct {
AllowedHashes []string `json:"allowed_hashes"`
}