gaffer_postgres (gaffer v0.2.0)

View Source

Pure SQL query builder and serializer for Postgres drivers.

Summary

Types

A list of queries to be run in one transaction.

A parameterized SQL query.

Functions

Query that fetches the current schema version.

Queries to create the migrations table if it does not exist.

Query that aggregates job counts and timestamps per state.

Query to atomically claim available jobs for execution.

Query to delete a job by ID.

Query to fetch a job by ID.

Query to list jobs matching the given filters.

Query to delete jobs older than per-state cutoffs for a queue.

Returns upsert queries for a single encoded job.

Queries to roll back a migration and decrement the version.

Queries to apply a migration and record its version.

Sorted list of all schema migrations as {Version, Up, Down} tuples.

Query to delete a queue by name.

Query to check whether a queue name exists.

Query to register a queue name. No-op if already registered.

Query to list all registered queue names.

Types

queries()

-type queries() :: [query()].

A list of queries to be run in one transaction.

query()

-type query() :: {QueryString :: iodata(), Values :: list()}.

A parameterized SQL query.

The QueryString will contain $1 etc. which each will correspond to the nth value in Values.

Functions

applied_version()

-spec applied_version() -> queries().

Query that fetches the current schema version.

ensure_migrations_table()

-spec ensure_migrations_table() -> queries().

Queries to create the migrations table if it does not exist.

info(Queue)

-spec info(gaffer:queue()) -> queries().

Query that aggregates job counts and timestamps per state.

job_claim/2

-spec job_claim(map(), map()) -> queries().

Query to atomically claim available jobs for execution.

job_delete(ID)

-spec job_delete(term()) -> queries().

Query to delete a job by ID.

job_get(ID)

-spec job_get(term()) -> queries().

Query to fetch a job by ID.

job_list/1

-spec job_list(map()) -> queries().

Query to list jobs matching the given filters.

job_prune(Queue, Opts)

-spec job_prune(gaffer:queue(), map()) -> queries().

Query to delete jobs older than per-state cutoffs for a queue.

job_write(Encoded)

-spec job_write(map()) -> queries().

Returns upsert queries for a single encoded job.

migrate_down/1

-spec migrate_down({pos_integer(), _, queries()}) -> queries().

Queries to roll back a migration and decrement the version.

migrate_up/1

-spec migrate_up({pos_integer(), queries(), _}) -> queries().

Queries to apply a migration and record its version.

migrations(Opts)

-spec migrations(Opts :: map()) -> [{Version :: pos_integer(), Up :: queries(), Down :: queries()}].

Sorted list of all schema migrations as {Version, Up, Down} tuples.

queue_delete(Name)

-spec queue_delete(gaffer:queue()) -> queries().

Query to delete a queue by name.

queue_exists(Name)

-spec queue_exists(gaffer:queue()) -> queries().

Query to check whether a queue name exists.

queue_insert(Name)

-spec queue_insert(gaffer:queue()) -> queries().

Query to register a queue name. No-op if already registered.

queue_list()

-spec queue_list() -> queries().

Query to list all registered queue names.