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
- Use this to make
TaskTables
. TaskTables
is used for creating the necessary tables/views/functions in a postgres database. It implementsTaskTableProvider
and can be passed tocrate::Task
andcrate::Worker
that use it for finding out what postgres entities to use.
Enums
Traits
- 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. - 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 aString
or&str
. But you can also use a custom enum that implements this trait.
Functions
- Sets the
in_progress
flag tofalse
for any tasks that have been in progress for longer thanmax_allowed_last_update
.