database

package
v0.0.0-...-9c214a8 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2015 License: MIT Imports: 4 Imported by: 0

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 NewInMem

func NewInMem() *InMem

NewInMem returns a new empty InMem database.

func (*InMem) CreateWorker

func (db *InMem) CreateWorker(worker Worker) error

CreateWorker is used to store a new worker in the database.

func (*InMem) DeleteWorker

func (db *InMem) DeleteWorker(workerID string) error

DeleteWorker is used to remove a worker from the database.

func (*InMem) GetWorker

func (db *InMem) GetWorker(workerID string) (Worker, error)

GetWorker is used to retrieve a worker that was previously stored in the database.

func (*InMem) ListWorkers

func (db *InMem) ListWorkers() ([]Worker, error)

ListWorkers is used to list all the workers in the database

func (*InMem) UpdateWorker

func (db *InMem) UpdateWorker(worker Worker) error

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

func (db *Postgres) CreateWorker(worker Worker) error

CreateWorker is used to store a new worker in the database.

func (*Postgres) DeleteWorker

func (db *Postgres) DeleteWorker(workerID string) error

DeleteWorker is used to remove a worker from the database.

func (*Postgres) GetWorker

func (db *Postgres) GetWorker(workerID string) (Worker, error)

GetWorker is used to retrieve a worker that was previously stored in the database.

func (*Postgres) ListWorkers

func (db *Postgres) ListWorkers() ([]Worker, error)

ListWorkers is used to list all the workers in the database

func (*Postgres) UpdateWorker

func (db *Postgres) UpdateWorker(worker Worker) error

UpdateWorker is used to update a previously stored worker in the database.

type PostgresConfig

type PostgresConfig struct {
	URL          string
	MaxOpenConns int
}

type Worker

type Worker struct {
	ID          string
	Queue       string
	MaxJobCount int
	Attributes  map[string]string
}

Jump to

Keyboard shortcuts

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