db

package
v0.0.0-...-7131cb1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeSubcription    int = 0
	WalletSubscription int = 1

	TelegramSubscription int = 0
	NtfySubscription     int = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	Error    string
	Time     time.Time
	Duration time.Duration
	Warning  bool
}

type DBLog

type DBLog struct {
}

func (*DBLog) Error

func (d *DBLog) Error(ctx context.Context, s string, i ...interface{})

func (*DBLog) Info

func (d *DBLog) Info(ctx context.Context, s string, i ...interface{})

func (*DBLog) LogMode

func (d *DBLog) LogMode(level logger.LogLevel) logger.Interface

func (*DBLog) Trace

func (d *DBLog) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (*DBLog) Warn

func (d *DBLog) Warn(ctx context.Context, s string, i ...interface{})

type HealthStatus

type HealthStatus struct {
	SatelliteID  NodeID
	OnlineScore  float64
	Disqualified time.Time
	SuspendedAt  time.Time
}

type HealthyReport

type HealthyReport struct {
	AllHealthy bool
	Statuses   []HealthStatus
}

type Measurement

type Measurement struct {
	Received time.Time
	Value    int
}

type Node

type Node struct {
	ID           NodeID `gorm:"primaryKey"`
	FirstCheckIn time.Time
	LastCheckIn  time.Time
	FreeDisk     int64
	Address      string

	OperatorWallet string `json:"OperatorWallet,omitempty"`

	Version    string
	CommitHash string
	Timestamp  time.Time
	Release    bool

	Health string
}

type NodeID

type NodeID struct {
	storj.NodeID
}

func (*NodeID) GormDataType

func (n *NodeID) GormDataType() string

func (*NodeID) Scan

func (n *NodeID) Scan(value interface{}) error

func (*NodeID) Value

func (n *NodeID) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type NodeStat

type NodeStat struct {
	Enabled         bool
	UsedSpace       StatRecord
	UploadedBytes   StatRecord
	DownloadedBytes StatRecord
}

type Persistence

type Persistence struct {
	// contains filtered or unexported fields
}

func NewPersistence

func NewPersistence(db *gorm.DB) *Persistence

func (*Persistence) Get

func (n *Persistence) Get(id NodeID) (Node, error)

func (*Persistence) GetStat

func (n *Persistence) GetStat(ctx context.Context, nodeID NodeID, key string) (stat Stat, err error)

func (*Persistence) GetStatus

func (n *Persistence) GetStatus(id NodeID) (map[string]Status, error)

func (*Persistence) GetUsedSatellites

func (n *Persistence) GetUsedSatellites(id NodeID) ([]SatelliteUsage, error)

func (*Persistence) GetWallet

func (n *Persistence) GetWallet(walletAddress common.Address) (Wallet, error)

func (*Persistence) GetWalletWithNodes

func (n *Persistence) GetWalletWithNodes(walletAddress common.Address) (Wallet, []Node, error)

func (*Persistence) Init

func (n *Persistence) Init() error

func (*Persistence) LatestStat

func (n *Persistence) LatestStat(ctx context.Context, nodeID NodeID) (stat StatCollection, err error)

func (*Persistence) ListNodes

func (n *Persistence) ListNodes() ([]Node, error)

func (*Persistence) ListNodesInternal

func (n *Persistence) ListNodesInternal() ([]Node, error)

func (*Persistence) RefreshViews

func (n *Persistence) RefreshViews(ctx context.Context)

func (*Persistence) SatelliteList

func (n *Persistence) SatelliteList() ([]UsedSatellite, error)

func (*Persistence) SaveTelemetry

func (n *Persistence) SaveTelemetry(t Telemetry) error

func (*Persistence) SaveWallet

func (n *Persistence) SaveWallet(w Wallet) error

func (*Persistence) UpdateCheckin

func (n *Persistence) UpdateCheckin(node Node) error

func (*Persistence) UpdateSatellites

func (n *Persistence) UpdateSatellites(node Node, statuses []HealthStatus) error

func (*Persistence) UpdateStatus

func (n *Persistence) UpdateStatus(id NodeID, checked map[string]CheckResult) error

type Satellite

type Satellite struct {
	ID          NodeID `gorm:"primaryKey"`
	Address     *string
	Description *string
}

type SatelliteUsage

type SatelliteUsage struct {
	NodeID       NodeID
	Satellite    Satellite
	SatelliteID  NodeID
	Disqualified time.Time
	Suspended    time.Time
	OnlineScore  float64
}

type Stat

type Stat struct {
	Name   string
	NodeID NodeID
	Values []Measurement
}

type StatCollection

type StatCollection struct {
	Records []StatRecord
}

func (*StatCollection) AsNodeStat

func (c *StatCollection) AsNodeStat() NodeStat

func (*StatCollection) Get

func (c *StatCollection) Get(key string, field string) StatRecord

func (*StatCollection) Insert

func (c *StatCollection) Insert(record StatRecord)

type StatRecord

type StatRecord struct {
	Received time.Time
	Key      string
	Field    string
	Value    float64
	Actual   bool
}

type Status

type Status struct {
	ID          NodeID `gorm:"primaryKey"`
	Check       string `gorm:"primaryKey"`
	LastChecked time.Time
	Error       string
	Duration    time.Duration
	Warning     bool
}

type Subscription

type Subscription struct {
	Destination     string `gorm:"primaryKey"`
	DestinationType int    `gorm:"primaryKey"`
	Base            string `gorm:"primaryKey"`
	BaseType        int    `gorm:"primaryKey"`
}

type Subscriptions

type Subscriptions struct {
	// contains filtered or unexported fields
}

func NewSubscriptions

func NewSubscriptions(db *gorm.DB) *Subscriptions

func (*Subscriptions) GetTargets

func (s *Subscriptions) GetTargets(subscriptionType int, id string) (subs []Subscription, err error)

func (*Subscriptions) ListSubscriptions

func (s *Subscriptions) ListSubscriptions(destType int, dest string) (subs []Subscription, err error)

func (*Subscriptions) Subscribe

func (s *Subscriptions) Subscribe(subscription Subscription) error

func (*Subscriptions) Unsubscribe

func (s *Subscriptions) Unsubscribe(subscription Subscription) error

type Telemetry

type Telemetry struct {
	NodeID   NodeID    `gorm:"primaryKey"`
	Key      string    `gorm:"primaryKey"`
	Field    string    `gorm:"primaryKey"`
	Received time.Time `gorm:"primaryKey"`
	Value    float64
}

type UsedSatellite

type UsedSatellite struct {
	Satellite Satellite
	Count     int
}

type Wallet

type Wallet struct {
	Address     string `gorm:"primaryKey"`
	NtfyChannel string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL