Documentation ¶
Index ¶
- Variables
- type ContractBilling
- type DBContract
- type Database
- type Farm
- type Node
- type NodePower
- type NodesDistribution
- type PostgresDatabase
- func (d *PostgresDatabase) Close() error
- func (p *PostgresDatabase) DeleteOldGpus(ctx context.Context, nodeTwinIds []uint32, expiration int64) error
- func (d *PostgresDatabase) GetConnectionString() string
- func (d *PostgresDatabase) GetContract(ctx context.Context, contractID uint32) (DBContract, error)
- func (d *PostgresDatabase) GetContractBills(ctx context.Context, contractID uint32, limit types.Limit) ([]ContractBilling, uint, error)
- func (d *PostgresDatabase) GetContracts(ctx context.Context, filter types.ContractFilter, limit types.Limit) ([]DBContract, uint, error)
- func (d *PostgresDatabase) GetFarm(ctx context.Context, farmID uint32) (Farm, error)
- func (d *PostgresDatabase) GetFarms(ctx context.Context, filter types.FarmFilter, limit types.Limit) ([]Farm, uint, error)
- func (p *PostgresDatabase) GetHealthyNodeTwinIds(ctx context.Context) ([]uint32, error)
- func (p *PostgresDatabase) GetLastNodeTwinID(ctx context.Context) (uint32, error)
- func (d *PostgresDatabase) GetNode(ctx context.Context, nodeID uint32) (Node, error)
- func (p *PostgresDatabase) GetNodeTwinIDsAfter(ctx context.Context, twinID uint32) ([]uint32, error)
- func (d *PostgresDatabase) GetNodes(ctx context.Context, filter types.NodeFilter, limit types.Limit) ([]Node, uint, error)
- func (d *PostgresDatabase) GetStats(ctx context.Context, filter types.StatsFilter) (types.Stats, error)
- func (d *PostgresDatabase) GetTwins(ctx context.Context, filter types.TwinFilter, limit types.Limit) ([]types.Twin, uint, error)
- func (d *PostgresDatabase) Initialize() error
- func (p *PostgresDatabase) UpsertNetworkSpeed(ctx context.Context, speeds []types.Speed) error
- func (p *PostgresDatabase) UpsertNodeDmi(ctx context.Context, dmis []types.Dmi) error
- func (p *PostgresDatabase) UpsertNodeHealth(ctx context.Context, healthReports []types.HealthReport) error
- func (p *PostgresDatabase) UpsertNodeIpv6Report(ctx context.Context, ips []types.HasIpv6) error
- func (p *PostgresDatabase) UpsertNodesGPU(ctx context.Context, gpus []types.NodeGPU) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNodeNotFound node not found ErrNodeNotFound = errors.New("node not found") // ErrFarmNotFound farm not found ErrFarmNotFound = errors.New("farm not found") //ErrViewNotFound ErrResourcesCacheTableNotFound = errors.New("ERROR: relation \"resources_cache\" does not exist (SQLSTATE 42P01)") // ErrContractNotFound contract not found ErrContractNotFound = errors.New("contract not found") )
Functions ¶
This section is empty.
Types ¶
type ContractBilling ¶ added in v0.11.3
type ContractBilling types.ContractBilling
type DBContract ¶
type DBContract struct { ContractID uint TwinID uint State string CreatedAt uint Name string NodeID uint DeploymentData string DeploymentHash string NumberOfPublicIps uint Type string FarmName string FarmId uint64 }
DBContract is contract info
type Database ¶
type Database interface { GetConnectionString() string // server getters GetStats(ctx context.Context, filter types.StatsFilter) (types.Stats, error) GetNode(ctx context.Context, nodeID uint32) (Node, error) GetFarm(ctx context.Context, farmID uint32) (Farm, error) GetNodes(ctx context.Context, filter types.NodeFilter, limit types.Limit) ([]Node, uint, error) GetFarms(ctx context.Context, filter types.FarmFilter, limit types.Limit) ([]Farm, uint, error) GetTwins(ctx context.Context, filter types.TwinFilter, limit types.Limit) ([]types.Twin, uint, error) GetContracts(ctx context.Context, filter types.ContractFilter, limit types.Limit) ([]DBContract, uint, error) GetContract(ctx context.Context, contractID uint32) (DBContract, error) GetContractBills(ctx context.Context, contractID uint32, limit types.Limit) ([]ContractBilling, uint, error) // indexer utils DeleteOldGpus(ctx context.Context, nodeTwinIds []uint32, expiration int64) error GetLastNodeTwinID(ctx context.Context) (uint32, error) GetNodeTwinIDsAfter(ctx context.Context, twinID uint32) ([]uint32, error) GetHealthyNodeTwinIds(ctx context.Context) ([]uint32, error) // indexer upserters UpsertNodesGPU(ctx context.Context, gpus []types.NodeGPU) error UpsertNodeHealth(ctx context.Context, healthReports []types.HealthReport) error UpsertNodeDmi(ctx context.Context, dmis []types.Dmi) error UpsertNetworkSpeed(ctx context.Context, speeds []types.Speed) error UpsertNodeIpv6Report(ctx context.Context, ips []types.HasIpv6) error }
Database interface for storing and fetching grid info
type Farm ¶
type Farm struct { Name string FarmID int TwinID int PricingPolicyID int Certification string StellarAddress string Dedicated bool PublicIps string }
Farm data about a farm which is calculated from the chain
type Node ¶
type Node struct { ID string NodeID int64 FarmID int64 FarmName string TwinID int64 Country string GridVersion int64 City string Uptime int64 Created int64 FarmingPolicyID int64 UpdatedAt int64 TotalCru int64 TotalMru int64 TotalSru int64 TotalHru int64 UsedCru int64 UsedMru int64 UsedSru int64 UsedHru int64 Domain string Gw4 string Gw6 string Ipv4 string Ipv6 string Certification string FarmDedicated bool `gorm:"farm_dedicated"` RentContractID int64 Renter int64 Rented bool Rentable bool SerialNumber string Longitude *float64 Latitude *float64 Power NodePower `gorm:"type:jsonb;serializer:json"` NumGPU int `gorm:"num_gpu"` ExtraFee uint64 NodeContractsCount uint64 `gorm:"node_contracts_count"` Healthy bool Bios types.BIOS `gorm:"type:jsonb;serializer:json"` Baseboard types.Baseboard `gorm:"type:jsonb;serializer:json"` Memory []types.Memory `gorm:"type:jsonb;serializer:json"` Processor []types.Processor `gorm:"type:jsonb;serializer:json"` UploadSpeed float64 DownloadSpeed float64 PriceUsd float64 }
Node data about a node which is calculated from the chain
type NodesDistribution ¶
NodesDistribution is the number of nodes per each country
type PostgresDatabase ¶
type PostgresDatabase struct {
// contains filtered or unexported fields
}
PostgresDatabase postgres db client
func NewPostgresDatabase ¶
func NewPostgresDatabase(host string, port int, user, password, dbname string, maxConns int, logLevel logger.LogLevel) (PostgresDatabase, error)
NewPostgresDatabase returns a new postgres db client
func (*PostgresDatabase) DeleteOldGpus ¶ added in v0.14.2
func (*PostgresDatabase) GetConnectionString ¶ added in v0.11.3
func (d *PostgresDatabase) GetConnectionString() string
func (*PostgresDatabase) GetContract ¶ added in v0.11.3
func (d *PostgresDatabase) GetContract(ctx context.Context, contractID uint32) (DBContract, error)
GetContract return a single contract info
func (*PostgresDatabase) GetContractBills ¶ added in v0.11.3
func (d *PostgresDatabase) GetContractBills(ctx context.Context, contractID uint32, limit types.Limit) ([]ContractBilling, uint, error)
GetContract return a single contract info
func (*PostgresDatabase) GetContracts ¶
func (d *PostgresDatabase) GetContracts(ctx context.Context, filter types.ContractFilter, limit types.Limit) ([]DBContract, uint, error)
GetContracts returns contracts filtered and paginated
func (*PostgresDatabase) GetFarms ¶
func (d *PostgresDatabase) GetFarms(ctx context.Context, filter types.FarmFilter, limit types.Limit) ([]Farm, uint, error)
GetFarms return farms filtered and paginated
func (*PostgresDatabase) GetHealthyNodeTwinIds ¶ added in v0.13.7
func (p *PostgresDatabase) GetHealthyNodeTwinIds(ctx context.Context) ([]uint32, error)
func (*PostgresDatabase) GetLastNodeTwinID ¶ added in v0.11.8
func (p *PostgresDatabase) GetLastNodeTwinID(ctx context.Context) (uint32, error)
func (*PostgresDatabase) GetNodeTwinIDsAfter ¶ added in v0.11.8
func (*PostgresDatabase) GetNodes ¶
func (d *PostgresDatabase) GetNodes(ctx context.Context, filter types.NodeFilter, limit types.Limit) ([]Node, uint, error)
GetNodes returns nodes filtered and paginated
func (*PostgresDatabase) GetStats ¶ added in v0.11.5
func (d *PostgresDatabase) GetStats(ctx context.Context, filter types.StatsFilter) (types.Stats, error)
GetStats returns aggregate info about the grid
func (*PostgresDatabase) GetTwins ¶
func (d *PostgresDatabase) GetTwins(ctx context.Context, filter types.TwinFilter, limit types.Limit) ([]types.Twin, uint, error)
GetTwins returns twins filtered and paginated
func (*PostgresDatabase) Initialize ¶ added in v0.13.0
func (d *PostgresDatabase) Initialize() error
func (*PostgresDatabase) UpsertNetworkSpeed ¶ added in v0.15.0
func (*PostgresDatabase) UpsertNodeDmi ¶ added in v0.15.0
func (*PostgresDatabase) UpsertNodeHealth ¶ added in v0.13.5
func (p *PostgresDatabase) UpsertNodeHealth(ctx context.Context, healthReports []types.HealthReport) error