Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateAverage(samples []uplink.GPUStatSample) uplink.GPUStatSample
- func DownsampleOverTime(interval time.Duration, database Database) error
- type Database
- type PostgresConn
- func (conn PostgresConn) AggregateData() (broadcast.AggregateData, error)
- func (conn PostgresConn) AppendDataPoint(sample uplink.GPUStatSample) error
- func (conn PostgresConn) AttachFile(attach broadcast.AttachFile) error
- func (conn PostgresConn) Downsample(int_now time.Time) error
- func (conn PostgresConn) DownsampleOld(cut time.Time) error
- func (conn PostgresConn) Drop() error
- func (conn PostgresConn) GetFile(hostname string, filename string) (broadcast.AttachFile, error)
- func (conn PostgresConn) HistoricalData(hostname string) (broadcast.HistoricalData, error)
- func (conn PostgresConn) LastSeen() ([]broadcast.WorkstationSeen, error)
- func (conn PostgresConn) LatestData() (broadcast.Workstations, error)
- func (conn PostgresConn) ListFiles(hostname string) ([]string, error)
- func (conn PostgresConn) NewMachine(machine broadcast.NewMachine) error
- func (conn PostgresConn) RemoveFile(remove broadcast.RemoveFile) error
- func (conn PostgresConn) RemoveMachine(machine broadcast.RemoveMachine) error
- func (conn PostgresConn) UpdateGPUContext(host string, packet uplink.GPUInfo) error
- func (conn PostgresConn) UpdateLastSeen(host string, now time.Time) error
- func (conn PostgresConn) UpdateMachine(machine broadcast.ModifyMachine) error
Constants ¶
View Source
const DefaultGroup string = "Shared"
default group to give to machines with a null or empty group
Variables ¶
View Source
var ( ErrMachineFoundTwice = errors.New("machine found twice") ErrMachineNotPresent = errors.New("adding gpu to non present machine") ErrGpuNotPresent = errors.New("appending to non present gpu") ErrNoSuchMachine = errors.New("could not find given machine") ErrFileNotPresent = errors.New("no file found") ErrNotImplemented = errors.New("method not implemented") )
Constant errors for failures in DB
Functions ¶
func CalculateAverage ¶
func CalculateAverage(samples []uplink.GPUStatSample) uplink.GPUStatSample
Types ¶
type Database ¶
type Database interface { // update the last seen time for a satellite to the current time UpdateLastSeen(host string, time time.Time) error // record a new data point for a satellite in the data store // will error if this gpu hasn't sent a context packet yet AppendDataPoint(sample uplink.GPUStatSample) error // Update the information for the GPU contained in uplink.GPUInfo UpdateGPUContext(host string, info uplink.GPUInfo) error // get the latest metrics for all approved machines LatestData() (broadcast.Workstations, error) // get last seen online metric for all machines LastSeen() ([]broadcast.WorkstationSeen, error) // create and modify machines in the database NewMachine(machine broadcast.NewMachine) error RemoveMachine(machine broadcast.RemoveMachine) error UpdateMachine(changes broadcast.ModifyMachine) error // downsample since certain time Downsample(time.Time) error // methods for interacting with files AttachFile(broadcast.AttachFile) error GetFile(hostname string, filename string) (broadcast.AttachFile, error) RemoveFile(broadcast.RemoveFile) error ListFiles(hostname string) ([]string, error) // Historical and aggregate data for graphs HistoricalData(hostname string) (broadcast.HistoricalData, error) AggregateData() (broadcast.AggregateData, error) }
define set of operations on the database that any provider will implement
type PostgresConn ¶
type PostgresConn struct {
// contains filtered or unexported fields
}
PostgresConn represents an open connection to a control database backed by postgres.
func (PostgresConn) AggregateData ¶
func (conn PostgresConn) AggregateData() (broadcast.AggregateData, error)
calculating the aggregate data
func (PostgresConn) AppendDataPoint ¶
func (conn PostgresConn) AppendDataPoint(sample uplink.GPUStatSample) error
func (PostgresConn) AttachFile ¶
func (conn PostgresConn) AttachFile(attach broadcast.AttachFile) error
func (PostgresConn) Downsample ¶
func (conn PostgresConn) Downsample(int_now time.Time) error
func (PostgresConn) DownsampleOld ¶
func (conn PostgresConn) DownsampleOld(cut time.Time) error
func (PostgresConn) Drop ¶
func (conn PostgresConn) Drop() error
Drop drops all tables on the connected database, then closes the connection.
This should only be used for testing purposes
func (PostgresConn) GetFile ¶
func (conn PostgresConn) GetFile(hostname string, filename string) (broadcast.AttachFile, error)
func (PostgresConn) HistoricalData ¶
func (conn PostgresConn) HistoricalData(hostname string) (broadcast.HistoricalData, error)
func (PostgresConn) LastSeen ¶
func (conn PostgresConn) LastSeen() ([]broadcast.WorkstationSeen, error)
func (PostgresConn) LatestData ¶
func (conn PostgresConn) LatestData() (broadcast.Workstations, error)
TODO: consider returning workstationGroup
func (PostgresConn) ListFiles ¶
func (conn PostgresConn) ListFiles(hostname string) ([]string, error)
func (PostgresConn) NewMachine ¶
func (conn PostgresConn) NewMachine(machine broadcast.NewMachine) error
func (PostgresConn) RemoveFile ¶
func (conn PostgresConn) RemoveFile(remove broadcast.RemoveFile) error
func (PostgresConn) RemoveMachine ¶
func (conn PostgresConn) RemoveMachine(machine broadcast.RemoveMachine) error
func (PostgresConn) UpdateGPUContext ¶
func (conn PostgresConn) UpdateGPUContext(host string, packet uplink.GPUInfo) error
func (PostgresConn) UpdateLastSeen ¶
func (conn PostgresConn) UpdateLastSeen(host string, now time.Time) error
implement interface
func (PostgresConn) UpdateMachine ¶
func (conn PostgresConn) UpdateMachine(machine broadcast.ModifyMachine) error
Update machine info
Click to show internal directories.
Click to hide internal directories.