database

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func Open

func Open(path string) (result *DB, err error)

Open connects and returns a pointer to a database object.

func (*DB) Add

func (db *DB) Add(input Node) (err error)

Add inserts a Node entry into the database if it doesn't exist already.

func (*DB) Get

func (db *DB) Get(id string) (result Node, err error)

Get searches for and returns a the corresponding entry from the database if the entry exists.

func (*DB) GetAllOlderThan added in v0.0.3

func (db *DB) GetAllOlderThan(input time.Duration) (result []Node, err error)

GetAllOld returns all of the old node entries in the database in a channel.

func (*DB) GetNodesOnline

func (db *DB) GetNodesOnline() (nodes int, err error)

GetNodesOnline calculates the number of nodes reporting to the database.

func (*DB) GetPoolSize

func (db *DB) GetPoolSize() (total float64, used float64, err error)

GetPoolSize return the sum the nodes total space and used space.

func (*DB) Remove

func (db *DB) Remove(id string) (err error)

Remove deletes an node from the database.

type Node

type Node struct {
	ID         string
	Username   string
	Email      string
	TotalSpace float64
	UsedSpace  float64
	LastSeen   time.Time
	FirstSeen  time.Time
}

Node defines the columns of data stored in the database.

Jump to

Keyboard shortcuts

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