db

package
v0.0.0-...-2119b44 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MaxAttachedNodes = 2

Variables

This section is empty.

Functions

This section is empty.

Types

type Connectivity

type Connectivity uint8
const (
	Unknown Connectivity = iota
	Offline Connectivity = 1 /* Not connected */
	Online  Connectivity = 2 /* Connected */
)

func ParseConnectivityState

func ParseConnectivityState(s string) Connectivity

func (*Connectivity) Scan

func (c *Connectivity) Scan(value interface{}) error

func (Connectivity) String

func (c Connectivity) String() string

func (Connectivity) Value

func (c Connectivity) Value() (driver.Value, error)

type Node

type Node struct {
	Id           string     `` /* 133-byte string literal not displayed */
	Name         string     `gorm:"type:string"`
	Status       NodeStatus `gorm:"not null"`
	Type         string     `gorm:"type:string;not null"`
	OrgId        uuid.UUID  `gorm:"type:uuid;not null"`
	ParentNodeId *string    `gorm:"type:string;expression:lower(id),where:deleted_at is null;size:23:default:null;"`
	Attached     []*Node    `gorm:"foreignKey:ParentNodeId"`
	Site         Site
	CreatedAt    time.Time
	UpdatedAt    time.Time
	DeletedAt    gorm.DeletedAt `gorm:"index"`
}

type NodeRepo

type NodeRepo interface {
	Add(*Node, func(*Node, *gorm.DB) error) error
	Get(ukama.NodeID) (*Node, error)
	GetForOrg(uuid.UUID) ([]Node, error)
	GetAll() ([]Node, error)
	Delete(ukama.NodeID, func(ukama.NodeID, *gorm.DB) error) error
	Update(*Node, func(*Node, *gorm.DB) error) error
	AttachNodes(nodeId ukama.NodeID, attachedNodeId []string) error
	DetachNode(detachNodeId ukama.NodeID) error
	GetNodeCount() (int64, int64, int64, error)
}

func NewNodeRepo

func NewNodeRepo(db sql.Db) NodeRepo

type NodeState

type NodeState uint8
const (
	Undefined   NodeState = iota
	Onboarded   NodeState = 1 /* First time when node connctes */
	Configured  NodeState = 2 /* After initial configuration */
	Active      NodeState = 3 /* Up and transmitting */
	Maintenance NodeState = 4 /* Upgardes / Downgrades */
	Faulty      NodeState = 5 /* Fault reported by node */
)

func ParseNodeState

func ParseNodeState(s string) NodeState

func (*NodeState) Scan

func (e *NodeState) Scan(value interface{}) error

func (NodeState) String

func (e NodeState) String() string

func (NodeState) Value

func (e NodeState) Value() (driver.Value, error)

type NodeStatus

type NodeStatus struct {
	gorm.Model
	NodeId string       `gorm:"uniqueIndex:nodestatus_idx,expression:lower(node_id),where:deleted_at is null"`
	Conn   Connectivity `gorm:"type:uint;not null"`
	State  NodeState    `gorm:"type:uint;not null"`
}

func (*NodeStatus) BeforeSave

func (n *NodeStatus) BeforeSave(tx *gorm.DB) (err error)

type NodeStatusRepo

type NodeStatusRepo interface {
	Update(*NodeStatus) error
	Get(ukama.NodeID) (*NodeStatus, error)
	Delete(ukama.NodeID) error
	GetAll() ([]NodeStatus, error)
	GetNodeCount() (onlineNodeCount, offlineNodeCount int64, err error)
}

func NewNodeStatusRepo

func NewNodeStatusRepo(db sql.Db) NodeStatusRepo

type Site

type Site struct {
	NodeId    string    `` /* 133-byte string literal not displayed */
	SiteId    uuid.UUID `gorm:"type:uuid"`
	NetworkId uuid.UUID `gorm:"type:uuid;"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (*Site) BeforeSave

func (s *Site) BeforeSave(tx *gorm.DB) (err error)

type SiteRepo

type SiteRepo interface {
	GetNodes(uuid.UUID) ([]Node, error)
	GetByNetwork(uuid.UUID) ([]Node, error)
	AddNode(*Site, func(*Site, *gorm.DB) error) error
	RemoveNode(ukama.NodeID) (*Site, error)
	GetFreeNodes() ([]Node, error)
	GetFreeNodesForOrg(uuid.UUID) ([]Node, error)
	IsAllocated(ukama.NodeID) (bool, *Site)
}

func NewSiteRepo

func NewSiteRepo(db sql.Db) SiteRepo

Jump to

Keyboard shortcuts

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