rdbms

package
v0.0.0-...-0f665fc Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	POSTGRES = "postgres"
)

Enumerated list of available database providers. Reserved for future.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaculaJob

type BaculaJob struct {
	Name      string `db:"name"`
	Level     string `db:"level"`
	Status    string `db:"jobstatus"`
	SchedTime uint32 `db:"schedtime"`
	StartTime uint32 `db:"starttime"`
	EndTime   uint32 `db:"endtime"`
	JobBytes  uint64 `db:"jobbytes"`
	JobFiles  uint64 `db:"jobfiles"`
}

type BaculaJobSummary

type BaculaJobSummary struct {
	Name          string `db:"name"`
	Level         string `db:"level"`
	TotalJobBytes uint64 `db:"totaljobbytes"`
	TotalJobFiles uint64 `db:"totaljobfiles"`
}

type BaculaSummary

type BaculaSummary struct {
	ScheduledJobs uint32 `db:"scheduledjobs"`
}

type DB

type DB struct {
	*sqlx.DB
}

func NewDB

func NewDB(datasource string) (*DB, error)

NewDB create new DB struct by datasource connection string with given provider

func (*DB) GetJobsSummary

func (db *DB) GetJobsSummary() ([]*BaculaJobSummary, error)

GetJobsSummary return summary of all jobs

func (*DB) GetLatestJobs

func (db *DB) GetLatestJobs() ([]*BaculaJob, error)

GetLatestJobs return total list of latest jobs

type Datastore

type Datastore interface {
	GetLatestJobs() ([]*BaculaJob, error)
	GetJobsSummary() ([]*BaculaJobSummary, error)
}

Datastore interface to models

We can then use this interface instead of the direct DB type throughout our application. Also we can easily create mock database responses for any unit tests.

Jump to

Keyboard shortcuts

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