Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { ListWorkers() ([]Worker, error) CreateWorker(worker Worker) error GetWorker(workerID string) (Worker, error) UpdateWorker(worker Worker) error DeleteWorker(workerID string) error }
A Database allows persisting workers and fetching them back.
type InMem ¶
type InMem struct {
// contains filtered or unexported fields
}
InMem is an implementation of Database that stores everything in memory. Meant to be used for tests that require a database.
func (*InMem) CreateWorker ¶
CreateWorker is used to store a new worker in the database.
func (*InMem) DeleteWorker ¶
DeleteWorker is used to remove a worker from the database.
func (*InMem) GetWorker ¶
GetWorker is used to retrieve a worker that was previously stored in the database.
func (*InMem) ListWorkers ¶
ListWorkers is used to list all the workers in the database
func (*InMem) UpdateWorker ¶
UpdateWorker is used to update a previously stored worker in the database.
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
Postgres is a Database backed by PostgreSQL
func NewPostgres ¶
func NewPostgres(config *PostgresConfig) (*Postgres, error)
NewPostgres connects to a database given a database URL, and creates a new Postgres instance backed by that database.
func (*Postgres) CreateWorker ¶
CreateWorker is used to store a new worker in the database.
func (*Postgres) DeleteWorker ¶
DeleteWorker is used to remove a worker from the database.
func (*Postgres) GetWorker ¶
GetWorker is used to retrieve a worker that was previously stored in the database.
func (*Postgres) ListWorkers ¶
ListWorkers is used to list all the workers in the database
func (*Postgres) UpdateWorker ¶
UpdateWorker is used to update a previously stored worker in the database.