Documentation ¶
Overview ¶
Package models for farmerbot models.
Package models for farmerbot ¶
Package models for farmerbot models.
Package models is a generated GoMock package.
Package models for farmerbot models.
Package models for farmerbot models.
Index ¶
- type Capacity
- type Config
- type ConsumableResources
- type Farm
- type MockSub
- type MockSubMockRecorder
- type Node
- type NodeOptions
- type Power
- type PowerState
- type RedisDB
- func (db *RedisDB) FilterOnNodes() ([]Node, error)
- func (db *RedisDB) GetFarm() (Farm, error)
- func (db *RedisDB) GetNode(nodeID uint32) (Node, error)
- func (db *RedisDB) GetNodes() ([]Node, error)
- func (db *RedisDB) GetPower() (Power, error)
- func (db *RedisDB) SaveConfig(config Config) error
- func (db *RedisDB) SetFarm(farm Farm) error
- func (db *RedisDB) SetNodes(nodes []Node) error
- func (db *RedisDB) SetPower(power Power) error
- func (db *RedisDB) UpdatesNodes(node Node) error
- type RedisManager
- type Sub
- type WakeupDate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capacity ¶
type Capacity struct { HRU uint64 `json:"HRU"` SRU uint64 `json:"SRU"` CRU uint64 `json:"CRU"` MRU uint64 `json:"MRU"` Ipv4 uint64 `json:"ipv4"` }
Capacity is node resource capacity
type Config ¶
type Config struct { Farm Farm `json:"farm"` Nodes []Node `json:"nodes"` Power Power `json:"power"` }
Config is the configuration for farmerbot
type ConsumableResources ¶
type ConsumableResources struct { OverProvisionCPU float64 `json:"overProvisionCPU,omitempty"` // how much we allow over provisioning the CPU range: [1;4] Total Capacity `json:"total"` Used Capacity `json:"used,omitempty"` }
ConsumableResources for node resources
type Farm ¶
type Farm struct { ID uint32 `json:"id"` Description string `json:"description,omitempty"` PublicIPs uint64 `json:"publicIPs,omitempty"` }
Farm of the farmer
type MockSub ¶
type MockSub struct {
// contains filtered or unexported fields
}
MockSub is a mock of Sub interface.
func NewMockSub ¶
func NewMockSub(ctrl *gomock.Controller) *MockSub
NewMockSub creates a new mock instance.
func (*MockSub) EXPECT ¶
func (m *MockSub) EXPECT() *MockSubMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSub) GetNodeRentContract ¶
GetNodeRentContract mocks base method.
type MockSubMockRecorder ¶
type MockSubMockRecorder struct {
// contains filtered or unexported fields
}
MockSubMockRecorder is the mock recorder for MockSub.
func (*MockSubMockRecorder) GetNodeRentContract ¶
func (mr *MockSubMockRecorder) GetNodeRentContract(node uint32) *gomock.Call
GetNodeRentContract indicates an expected call of GetNodeRentContract.
func (*MockSubMockRecorder) SetNodePowerState ¶
func (mr *MockSubMockRecorder) SetNodePowerState(identity, up interface{}) *gomock.Call
SetNodePowerState indicates an expected call of SetNodePowerState.
type Node ¶
type Node struct { ID uint32 `json:"id"` TwinID uint32 `json:"twinID"` FarmID uint32 `json:"farmID,omitempty"` Description string `json:"description,omitempty"` Certified bool `json:"certified,omitempty"` Dedicated bool `json:"dedicated,omitempty"` PublicConfig bool `json:"publicConfig,omitempty"` HasActiveRentContract bool `json:"hasActiveRentContract,omitempty"` PublicIPsUsed uint64 `json:"publicIPsUsed,omitempty"` WgPorts []uint16 `json:"wgPorts,omitempty"` Pools []pkg.PoolMetrics `json:"pools,omitempty"` Resources ConsumableResources `json:"resources"` PowerState PowerState `json:"powerState,omitempty"` TimeoutClaimedResources time.Time `json:"timeoutClaimedResources,omitempty"` LastTimePowerStateChanged time.Time `json:"lastTimePowerStateChanged,omitempty"` LastTimeAwake time.Time `json:"lastTimeAwake,omitempty"` }
Node represents a node in a farm
func FilterUnusedOnNodes ¶
FilterUnusedOnNodes filters nodes that are ON and unused
func FilterWakingOrShuttingNodes ¶
FilterWakingOrShuttingNodes filters nodes that are waking up or shutting down
func (*Node) CanClaimResources ¶
CanClaimResources checks if a node can claim some resources
func (*Node) ClaimResources ¶
ClaimResources claims the resources from a node
func (*Node) SetNodePower ¶
SetNodePower sets the node power
func (*Node) UpdateResources ¶
func (n *Node) UpdateResources(cap ConsumableResources)
UpdateResources updates the node resources
type NodeOptions ¶
type NodeOptions struct { Certified bool `json:"certified,omitempty"` Dedicated bool `json:"dedicated,omitempty"` PublicConfig bool `json:"publicConfig,omitempty"` PublicIPs uint64 `json:"publicIPs,omitempty"` Capacity Capacity `json:"capacity,omitempty"` }
NodeOptions represents the options to find a node
type Power ¶
type Power struct { WakeUpThreshold uint64 `json:"wakeUpThreshold"` PeriodicWakeup WakeupDate `json:"periodicWakeUp"` }
Power represents power configuration
type PowerState ¶
type PowerState struct { ON bool `json:"on,omitempty"` WakingUp bool `json:"wakingUp,omitempty"` OFF bool `json:"off,omitempty"` ShuttingDown bool `json:"shuttingDown,omitempty"` }
PowerState is the state of node's power
type RedisDB ¶
type RedisDB struct {
// contains filtered or unexported fields
}
RedisDB for saving config for farmerbot
func (*RedisDB) FilterOnNodes ¶
FilterOnNodes filters db ON nodes
func (*RedisDB) SaveConfig ¶
SaveConfig saves the configuration in the database
func (*RedisDB) UpdatesNodes ¶
UpdatesNodes adds or updates a node in the database
type RedisManager ¶
type RedisManager interface { GetFarm() (Farm, error) GetPower() (Power, error) GetNode(nodeID uint32) (Node, error) GetNodes() ([]Node, error) UpdatesNodes(node Node) error SetNodes(nodes []Node) error SetFarm(farm Farm) error SetPower(power Power) error SaveConfig(config Config) error FilterOnNodes() ([]Node, error) }
RedisManager represents interface for redis DB actions
type Sub ¶
type Sub interface { SetNodePowerState(identity substrate.Identity, up bool) (hash types.Hash, err error) GetNodeRentContract(node uint32) (uint64, error) }
Sub is substrate client interface
type WakeupDate ¶
WakeupDate is the date to wakeup all nodes
func (WakeupDate) MarshalJSON ¶
func (d WakeupDate) MarshalJSON() ([]byte, error)
MarshalJSON marshals the wakeup date
func (WakeupDate) PeriodicWakeupStart ¶
func (d WakeupDate) PeriodicWakeupStart() time.Time
PeriodicWakeupStart returns periodic wakeup start date
func (*WakeupDate) UnmarshalJSON ¶
func (d *WakeupDate) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the given JSON object into wakeUp date