Documentation
¶
Overview ¶
Package pgstore implements the job store ports on Postgres with pgx.
Index ¶
- Constants
- type DB
- type Filter
- type Leader
- type Listener
- func (l *Listener) Close(ctx context.Context) error
- func (l *Listener) Connect(ctx context.Context) error
- func (l *Listener) Listen(ctx context.Context, channel string) error
- func (l *Listener) Ping(ctx context.Context) error
- func (l *Listener) WaitForNotification(ctx context.Context) (job.Notification, error)
- type Names
- type PeriodicRow
- type QueueRow
- type Store
- func (s *Store) AcquireLease(ctx context.Context, name, id string, now time.Time, ttl time.Duration) (bool, error)
- func (s *Store) CancelRequested(ctx context.Context, ids []int64) ([]int64, error)
- func (s *Store) Complete(ctx context.Context, clientID string, cs []job.Completion) ([]int64, error)
- func (s *Store) CompleteTx(ctx context.Context, tx pgx.Tx, clientID string, ref job.Ref, now time.Time) error
- func (s *Store) DeleteFinalized(ctx context.Context, state job.State, cutoff time.Time, limit int) (int, error)
- func (s *Store) EnqueueTick(ctx context.Context, name string, tick time.Time, p job.InsertParams) (bool, error)
- func (s *Store) Fetch(ctx context.Context, p job.FetchParams) ([]*job.Row, error)
- func (s *Store) FetchByID(ctx context.Context, id int64, clientID string, now time.Time) (*job.Row, error)
- func (s *Store) Heartbeat(ctx context.Context, clientID string, now time.Time, refs []job.Ref) (int, error)
- func (s *Store) Insert(ctx context.Context, db DB, ps []job.InsertParams) ([]job.InsertResult, error)
- func (s *Store) JobDeleteAll(ctx context.Context, f Filter) (int, error)
- func (s *Store) JobGet(ctx context.Context, id int64) (*job.Row, error)
- func (s *Store) JobList(ctx context.Context, f Filter, limit int) ([]*job.Row, error)
- func (s *Store) JobUpdate(ctx context.Context, op string, f Filter, now time.Time, limit int) ([]*job.Row, error)
- func (s *Store) JobUpdateAll(ctx context.Context, op string, f Filter, now time.Time) (int, error)
- func (s *Store) KeyStats(ctx context.Context, queue string, limit int, withRunning bool) ([]job.KeyStat, error)
- func (s *Store) LastTicks(ctx context.Context) (map[string]time.Time, error)
- func (s *Store) LeaderGet(ctx context.Context, name string) (*Leader, error)
- func (s *Store) MarkPeriodicStart(ctx context.Context, name string, now time.Time) error
- func (s *Store) Names() Names
- func (s *Store) NewListener() *Listener
- func (s *Store) PeriodicList(ctx context.Context) ([]*PeriodicRow, error)
- func (s *Store) Pool() *pgxpool.Pool
- func (s *Store) PromoteDue(ctx context.Context, now time.Time, limit int) (int, error)
- func (s *Store) PruneTicks(ctx context.Context, cutoff time.Time) (int, error)
- func (s *Store) QueueDepths(ctx context.Context) ([]job.QueueDepth, error)
- func (s *Store) QueueHeartbeat(ctx context.Context, queue string, now time.Time) (bool, error)
- func (s *Store) QueueList(ctx context.Context) ([]*QueueRow, error)
- func (s *Store) QueueSetPaused(ctx context.Context, name string, paused bool, now time.Time) error
- func (s *Store) Reindex(ctx context.Context) (bool, error)
- func (s *Store) ReleaseLease(ctx context.Context, name, id string) error
- func (s *Store) RenewLease(ctx context.Context, name, id string, now time.Time, ttl time.Duration) (bool, error)
- func (s *Store) Rescue(ctx context.Context, cutoff time.Time, cs []job.Completion) (int, error)
- func (s *Store) ServedQueues(ctx context.Context, cutoff time.Time) ([]string, error)
- func (s *Store) StuckJobs(ctx context.Context, cutoff time.Time, limit int) ([]*job.Row, error)
Constants ¶
View Source
const ( OpCancel = "cancel" OpDiscard = "discard" OpRetry = "retry" )
View Source
const CopyThreshold = 10
View Source
const DefaultSchema = "public"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface {
Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
CopyFrom(ctx context.Context, table pgx.Identifier, cols []string, src pgx.CopyFromSource) (int64, error)
Begin(ctx context.Context) (pgx.Tx, error)
}
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener holds a dedicated connection for LISTEN.
func (*Listener) WaitForNotification ¶
type Names ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements the job store ports on Postgres.
func (*Store) AcquireLease ¶
func (*Store) CancelRequested ¶
func (*Store) Complete ¶
func (s *Store) Complete(ctx context.Context, clientID string, cs []job.Completion) ([]int64, error)
Complete writes the results of finished attempts.
func (*Store) CompleteTx ¶
func (*Store) DeleteFinalized ¶
func (*Store) EnqueueTick ¶
func (*Store) Insert ¶
func (s *Store) Insert(ctx context.Context, db DB, ps []job.InsertParams) ([]job.InsertResult, error)
Insert inserts jobs and returns one result per input.
func (*Store) JobDeleteAll ¶
func (*Store) JobUpdateAll ¶
func (*Store) MarkPeriodicStart ¶
func (*Store) NewListener ¶
NewListener returns a listener on the pool.
func (*Store) PeriodicList ¶
func (s *Store) PeriodicList(ctx context.Context) ([]*PeriodicRow, error)
func (*Store) PromoteDue ¶
func (*Store) PruneTicks ¶
func (*Store) QueueDepths ¶
func (*Store) QueueHeartbeat ¶
func (*Store) QueueSetPaused ¶
func (*Store) ReleaseLease ¶
func (*Store) RenewLease ¶
func (*Store) ServedQueues ¶
Click to show internal directories.
Click to hide internal directories.