Categorygithub.com/bubunyo/que-go
modulepackage
1.0.2
Repository: https://github.com/bubunyo/que-go.git
Documentation: pkg.go.dev

# README

que-go

GoDoc

Que-go is a fully interoperable Golang port of Chris Hanks' Ruby Que queuing library for PostgreSQL. Que uses PostgreSQL's advisory locks for speed and reliability.

Because que-go is an interoperable port of Que, you can enqueue jobs in Ruby (i.e. from a Rails app) and write your workers in Go. Or if you have a limited set of jobs that you want to write in Go, you can leave most of your workers in Ruby and just add a few Go workers on a different queue name. Or you can just write everything in Go :)

pgx PostgreSQL driver

This package uses the pgx Go PostgreSQL driver rather than the more popular pq. Because Que uses session-level advisory locks, we have to hold the same connection throughout the process of getting a job, working it, deleting it, and removing the lock.

Pq and the built-in database/sql interfaces do not offer this functionality, so we'd have to implement our own connection pool. Fortunately, pgx already has a perfectly usable one built for us. Even better, it offers better performance than pq due largely to its use of binary encoding.

Please see the godocs for more info and examples.

# Functions

NewClient creates a new Client that uses the pgx pool.
NewWorker returns a Worker that fetches Jobs from the Client and executes them using WorkMap.
NewWorkerPool creates a new WorkerPool with count workers using the Client c.
PrepareStatements prepares the required statements to run que on the provided *pgx.Conn.
PrepareStatementsWithPreparer prepares the required statements to run que on the provided Preparer.

# Variables

Returned by LockJob if a job could not be retrieved from the queue after several attempts because of concurrently running transactions.
ErrMissingType is returned when you attempt to enqueue a job with no Type specified.

# Structs

Client is a Que client that can add jobs to the queue and remove jobs from the queue.
ErrorRunAt is an type you to specify when exactly a job should run again after there is an error.
Job is a single unit of work for Que to perform.
Worker is a single worker that pulls jobs off the specified Queue.
WorkerPool is a pool of Workers, each working jobs from the queue Queue at the specified Interval using the WorkMap.

# Interfaces

Preparer defines the interface for types that support preparing statements.

# Type aliases

WorkFunc is a function that performs a Job.
WorkMap is a map of Job names to WorkFuncs that are used to perform Jobs of a given type.