Background task management library for Clojure.
Background task management library for Clojure.
(create-task! taskq task)
Create and returns a new task.
Create and returns a new task.
(list-tasks taskq
{:keys [from to topic sub-topic] :as filters}
{:keys [limit] :as cursor})
List all tasks for a given topic
.
List all tasks for a given `topic`.
(task taskq task-id)
Get task by task-id
. Returns nil when no task is found.
Get task by `task-id`. Returns nil when no task is found.
(tasks taskq task-group-id)
Get tasks for a given task-group-id
. Returns nil when no tasks are
found for the supplied input.
Get tasks for a given `task-group-id`. Returns nil when no tasks are found for the supplied input.
(worker {:keys [taskq topic pid pfn lease-time-ms keepalive-ms timeout-ms
max-poll-interval-ms]
:as opts})
Polls the task service on the given topic
for a task and when
available, obtains a lease for the task, and calls processor
function pfn
in a separate thread, passing the task as an
argument. It also spins up a sidecar thread (keepalive) to extend
the lease of the task periodically, while pfn is being executed.
processor-fn
- should accept task as an argument, perform thecleanup-leased-tasks
operation corresponding to the task and return a tuple containing
[event-name opts]. valid event-names and args are:
[:sokka/completed nil], [:sokka/failed, {:keys [error-message]}]
[:sokka/snoozed, {:keys [snooze-time]}].
keepalive-ms
- keepalive timeout, will be lease-time * 0.7
timeout-ms
- Time in ms after which the task will be interrupted
and marked as failed. This value can be overridden at the task
level, by setting timeout-ms
in the task itself. If the task times
out, the status of the task is set to :failed.
The worker polls for tasks using an exponentially increasing sleeper function to prevent the worker from flooding the queue with requests during inactivity.
Polls the task service on the given `topic` for a task and when available, obtains a lease for the task, and calls processor function `pfn` in a separate thread, passing the task as an argument. It also spins up a sidecar thread (keepalive) to extend the lease of the task periodically, while pfn is being executed. `processor-fn` - should accept task as an argument, perform thecleanup-leased-tasks operation corresponding to the task and return a tuple containing [event-name opts]. valid event-names and args are: [:sokka/completed nil], [:sokka/failed, {:keys [error-message]}] [:sokka/snoozed, {:keys [snooze-time]}]. `keepalive-ms` - keepalive timeout, will be lease-time * 0.7 `timeout-ms` - Time in ms after which the task will be interrupted and marked as failed. This value can be overridden at the task level, by setting `timeout-ms` in the task itself. If the task times out, the status of the task is set to :failed. The worker polls for tasks using an exponentially increasing sleeper function to prevent the worker from flooding the queue with requests during inactivity.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close