pg

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package pg implements backend.Interface using Postgres.

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Config:   backend.DefaultConfig,
	Database: "job_manager",
}

Functions

This section is empty.

Types

type Config

type Config struct {
	backend.Config

	Database string `json:"database" envconfig:"postgres_database"`
	Host     string `json:"host,omitempty" envconfig:"postgres_host"`
	Port     int    `json:"port,omitempty" envconfig:"postgres_port"`
	User     string `json:"user,omitempty" envconfig:"postgres_user"`
	Password string `json:"password,omitempty" envconfig:"postgres_pass"`
	SSLMode  string `json:"sslmode,omitempty" envconfig:"postgres_sslmode"`
}

func (Config) DSN

func (c Config) DSN() string

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

func New

func New(providers ...ProviderFunc) *Postgres

New returns a new instance of a postgresql backend.

example dsn: user=jack password=secret host=pg.example.com port=5432 dbname=mydb sslmode=verify-ca

func (*Postgres) AckJobs

func (pg *Postgres) AckJobs(ctx context.Context, results *resource.Acks) error

func (*Postgres) BlockQueues added in v0.4.0

func (pg *Postgres) BlockQueues(ctx context.Context, queues []string) error

func (*Postgres) Close

func (pg *Postgres) Close() error

func (*Postgres) DeleteJobKeys

func (pg *Postgres) DeleteJobKeys(ctx context.Context, keys []string) error

func (*Postgres) DeleteJobUniqueArgs

func (pg *Postgres) DeleteJobUniqueArgs(ctx context.Context, ids, keys []string) error

func (*Postgres) DeleteQueues added in v0.4.0

func (pg *Postgres) DeleteQueues(ctx context.Context, queues []string) error

func (*Postgres) DequeueJobs

func (pg *Postgres) DequeueJobs(ctx context.Context, limit int, opts *resource.JobListParams) (*resource.Jobs, error)

func (*Postgres) EnqueueJobs

func (pg *Postgres) EnqueueJobs(ctx context.Context, jobs *resource.Jobs) (*resource.Jobs, error)

func (*Postgres) GetJobByID

func (pg *Postgres) GetJobByID(ctx context.Context, id string, opts *resource.GetByIDOpts) (*resource.Job, error)

func (*Postgres) GetJobUniqueArgs

func (pg *Postgres) GetJobUniqueArgs(ctx context.Context, keys []string) ([]string, bool, error)

func (*Postgres) GetQueue

func (pg *Postgres) GetQueue(ctx context.Context, name string, opts *resource.GetByIDOpts) (*resource.Queue, error)

func (*Postgres) Handler

func (pg *Postgres) Handler() http.Handler

func (*Postgres) InvalidateJobs

func (pg *Postgres) InvalidateJobs(ctx context.Context) error

func (*Postgres) ListJobs

func (pg *Postgres) ListJobs(ctx context.Context, limit int, opts *resource.JobListParams) (*resource.Jobs, error)

func (*Postgres) ListQueues

func (pg *Postgres) ListQueues(ctx context.Context, opts *resource.QueueListParams) (*resource.Queues, error)

func (*Postgres) Middleware

func (pg *Postgres) Middleware() func(next http.Handler) http.Handler

Middleware provides transaction middleware.

func (*Postgres) PauseQueues added in v0.4.0

func (pg *Postgres) PauseQueues(ctx context.Context, queues []string) error

func (*Postgres) Ping

func (pg *Postgres) Ping(ctx context.Context) error

func (*Postgres) Reap

func (pg *Postgres) Reap(ctx context.Context, cfg *backend.ReaperConfig) error

Reap cleans up old jobs and queue versions.

func (*Postgres) Reset

func (pg *Postgres) Reset(ctx context.Context) error

func (*Postgres) SaveQueue

func (pg *Postgres) SaveQueue(ctx context.Context, queue *resource.Queue) (*resource.Queue, error)

func (*Postgres) SetJobUniqueArgs

func (pg *Postgres) SetJobUniqueArgs(ctx context.Context, ids, keys []string) error

func (*Postgres) Stats

func (pg *Postgres) Stats(ctx context.Context, queue string) (*resource.Stats, error)

func (*Postgres) UnblockQueues added in v0.4.0

func (pg *Postgres) UnblockQueues(ctx context.Context, queues []string) error

func (*Postgres) UnpauseQueues added in v0.4.0

func (pg *Postgres) UnpauseQueues(ctx context.Context, queues []string) error

type ProviderFunc

type ProviderFunc func(p *Postgres) *Postgres

func WithConfig

func WithConfig(cfg Config) ProviderFunc

Directories

Path Synopsis
Package migrations contains migration data.
Package migrations contains migration data.

Jump to

Keyboard shortcuts

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