Crate pg_taskq

Source
Expand description

pg-taskq is a simple postgres-based distributed task queue. It is:

  • pluggable: install it under a custom schema with custom table names, easily uninstall it again
  • simple: in postgres there is 1 table, 1 view, 2 plpgsql functions. In Rust there is a task and worker interface
  • async: using tokio
  • two-way: task can easily wait on being processed, producing output
  • hierarchical: tasks can have sub-tasks that get automatically processed bottom-up

I made this to scratch my own itch to have a flexible, persistent and distributed task queue for various long-running processing tasks without having to maintain additional services and infrastructure. This thing is likely not production ready nor is it battle tested — use at your own risk.

For a worker-producer example see this project.

Structs§

Task
TaskBuilder
TaskTableBuilder
Use this to make TaskTables.
TaskTables
TaskTables is used for creating the necessary tables/views/functions in a postgres database. It implements TaskTableProvider and can be passed to crate::Task and crate::Worker that use it for finding out what postgres entities to use.
Worker

Enums§

Error

Traits§

TaskTableProvider
Used to make the postgres table/view/function names pluggable. You’ll typically want to use its implementor TaskTables that can be instantiated with a customizable schema and name prefix.
TaskType
A TaskType is used to group kinds of tasks. This is useful if you have specialized workers, where one worker only processes on or a few types of tasks. You might also think of it as the “topic”. In the simplest case just use a String or &str. But you can also use a custom enum that implements this trait.

Functions§

connect
fixup_stale_tasks
Sets the in_progress flag to false for any tasks that have been in progress for longer than max_allowed_last_update.

Type Aliases§

Result