Thread-pool-based worker pool that claims jobs from the queue and dispatches them to registered task functions.
All worker threads share one queue and one worker-id, so jobs are claimed atomically in batches and distributed via take-job!. The pool does not own the job-system or emitter; callers supply those at creation time.
Task functions receive a context map with :job, :job-system, and :worker-id. They signal outcomes as follows: • return any value (including nil) - job succeeds (WorkerCompletesJob) • return (partial-success m) - partial success (WorkerReportsPartialSuccess) • throw any Throwable - job fails (WorkerFailsJob)
Events emitted: :pool/start - pool is started (includes :concurrency) :pool/stop - pool has stopped (includes :forced? when force-stop!) :job/completed - task fn returned normally :job/failed - task fn threw; job retry scheduled :job/exhausted - task fn threw on the final allowed attempt :job/partial-success - task fn returned a partial-success value :worker/error - infrastructure exception outside task execution
Thread-pool-based worker pool that claims jobs from the queue and dispatches them to registered task functions. All worker threads share one queue and one worker-id, so jobs are claimed atomically in batches and distributed via take-job!. The pool does not own the job-system or emitter; callers supply those at creation time. Task functions receive a context map with :job, :job-system, and :worker-id. They signal outcomes as follows: • return any value (including nil) - job succeeds (WorkerCompletesJob) • return (partial-success m) - partial success (WorkerReportsPartialSuccess) • throw any Throwable - job fails (WorkerFailsJob) Events emitted: :pool/start - pool is started (includes :concurrency) :pool/stop - pool has stopped (includes :forced? when force-stop!) :job/completed - task fn returned normally :job/failed - task fn threw; job retry scheduled :job/exhausted - task fn threw on the final allowed attempt :job/partial-success - task fn returned a partial-success value :worker/error - infrastructure exception outside task execution
(active-workers pool)Returns the number of worker threads currently executing a task.
Returns the number of worker threads currently executing a task.
(create-pool job-system task-registry emitter)(create-pool job-system task-registry emitter config)Creates a worker pool. Call start! to begin processing jobs. task-registry is a map of task-identifier strings to handler functions. Each handler fn receives {:job job :job-system sys :worker-id wid}.
Creates a worker pool. Call start! to begin processing jobs.
task-registry is a map of task-identifier strings to handler functions.
Each handler fn receives {:job job :job-system sys :worker-id wid}.(force-stop! pool)Immediately interrupts all worker threads and stops the pool. Returns pool.
Immediately interrupts all worker threads and stops the pool. Returns pool.
(partial-success partial-results)Wraps partial-results so the pool treats the task return as a partial success. partial-results keys: :completed-steps, :failed-steps, :retry-from-step, :results.
Wraps partial-results so the pool treats the task return as a partial success. partial-results keys: :completed-steps, :failed-steps, :retry-from-step, :results.
(partial-success? v)Returns true if v was produced by partial-success.
Returns true if v was produced by partial-success.
(running? pool)Returns true if the pool has been started and not yet stopped.
Returns true if the pool has been started and not yet stopped.
(start! pool)Starts the worker pool. Throws if already running. Returns pool.
Starts the worker pool. Throws if already running. Returns pool.
(stats pool)Returns a snapshot of pool operational metrics. Keys: :active, :completed, :failed, :errors.
Returns a snapshot of pool operational metrics. Keys: :active, :completed, :failed, :errors.
(stop! pool)(stop! pool timeout-ms)Gracefully stops the pool. Waits up to timeout-ms for in-flight jobs. Remaining buffered-but-unclaimed jobs stay locked in the DB and are recovered by ResetOverdueJobs after config.lock_timeout. Returns pool.
Gracefully stops the pool. Waits up to timeout-ms for in-flight jobs. Remaining buffered-but-unclaimed jobs stay locked in the DB and are recovered by ResetOverdueJobs after config.lock_timeout. Returns pool.
(worker-id pool)Returns the worker-id used for all job claims from this pool.
Returns the worker-id used for all job claims from this pool.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |