Documentation ¶
Overview ¶
Package backend manages storing data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = Config{ QueueHistoryLimit: 10, ReapAge: 24 * time.Hour * 60, }
View Source
var ErrBlocked = errors.New("backend: queue blocked")
View Source
var ErrInvalidResource = errors.New("backend: invalid resource")
ErrInvalidResource should be returned when the resource is missing a field required for storage, like an ID that can't be autogenerated. TODO this should be a struct
View Source
var ErrInvalidState = errors.New("backend: invalid state")
View Source
var ErrNotAuthorized = errors.New("backend: not authorized")
View Source
var ErrNotFound = errors.New("backend: not found")
View Source
var ( JobIncludes = map[string]bool{ "checkin": true, "result": true, } )
Functions ¶
Types ¶
type Config ¶
type Config struct { // QueueHistoryLimit is the maximum number of resource versions to store. QueueHistoryLimit int `json:"queue_history_limit" envconfig:"queue_history_limit"` ReapAge time.Duration `json:"reap_age" envconfig:"reap_age"` ReapMax int `json:"reap_max" envconfig:"reap_max"` TestMode bool `json:"test_mode" envconfig:"test"` Debug bool Logger *logger.Logger }
type HandlerProvider ¶
type Interface ¶
type Interface interface { Ping(ctx context.Context) error // Reset resets the backend. For testing. Reset(ctx context.Context) error GetQueue(ctx context.Context, job string, opts *resource.GetByIDOpts) (*resource.Queue, error) SaveQueue(ctx context.Context, queue *resource.Queue) (*resource.Queue, error) ListQueues(ctx context.Context, opts *resource.QueueListParams) (*resource.Queues, error) DeleteQueues(ctx context.Context, queues []string) error PauseQueues(ctx context.Context, queues []string) error UnpauseQueues(ctx context.Context, queues []string) error BlockQueues(ctx context.Context, queues []string) error UnblockQueues(ctx context.Context, queues []string) error EnqueueJobs(ctx context.Context, jobs *resource.Jobs) (*resource.Jobs, error) DequeueJobs(ctx context.Context, limit int, opts *resource.JobListParams) (*resource.Jobs, error) AckJobs(ctx context.Context, results *resource.Acks) error GetJobUniqueArgs(ctx context.Context, keys []string) ([]string, bool, error) SetJobUniqueArgs(ctx context.Context, ids, keys []string) error DeleteJobUniqueArgs(ctx context.Context, ids, keys []string) error GetJobByID(ctx context.Context, id string, opts *resource.GetByIDOpts) (*resource.Job, error) ListJobs(ctx context.Context, limit int, opts *resource.JobListParams) (*resource.Jobs, error) Stats(ctx context.Context, queue string) (*resource.Stats, error) }
Interface defines the backend interface. Some required properties:
- UTC
- handle resource versions, conflicts
- safe for concurrent operations
func FromMiddleware ¶
type Invalidator ¶
type MiddlewareProvider ¶
type NoopInvalidator ¶
type NoopInvalidator struct{}
func (*NoopInvalidator) InvalidateJobs ¶
func (iv *NoopInvalidator) InvalidateJobs(ctx context.Context) error
type NoopReaper ¶
type NoopReaper struct{}
func (*NoopReaper) Reap ¶
func (r *NoopReaper) Reap(ctx context.Context, cfg *ReaperConfig) error
type Reaper ¶
type Reaper interface {
Reap(ctx context.Context, cfg *ReaperConfig) error
}
Reaper adds functionality to clean up old job data.
type ReaperConfig ¶
type VersionConflictError ¶
func NewVersionConflictError ¶
func NewVersionConflictError(prev, curr *resource.Version, resource, resourceID string) *VersionConflictError
func (*VersionConflictError) Error ¶
func (e *VersionConflictError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mem is a minimal reference implementation of backend.Interface suitable for use in tests.
|
Package mem is a minimal reference implementation of backend.Interface suitable for use in tests. |
Package pg implements backend.Interface using Postgres.
|
Package pg implements backend.Interface using Postgres. |
migrations
Package migrations contains migration data.
|
Package migrations contains migration data. |
Click to show internal directories.
Click to hide internal directories.