-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathworker.clj
More file actions
30 lines (26 loc) · 1.08 KB
/
Copy pathworker.clj
File metadata and controls
30 lines (26 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(ns example-c.worker
(:require [example-c.enqueue-jobs :as enqueue-jobs]
[examples.common :as common]
[next.jdbc :as jdbc]
[proletarian.worker :as worker]))
(defn on-shutdown
[ds]
(common/summary ds))
(defn run
[_]
(let [ds (jdbc/get-datasource (:jdbc-url common/config))]
(common/preamble ds)
(println "Starting worker for :proletarian/default queue with polling interval 1 s")
(let [worker (worker/create-queue-worker ds
enqueue-jobs/handle-job!
{:proletarian/polling-interval-ms 1000
:proletarian/on-shutdown (partial on-shutdown ds)
:proletarian/install-jvm-shutdown-hook? true
:proletarian/handler-fn-mode :advanced})]
(worker/start! worker)
worker)))
(comment
;; Create and start a worker
(def +worker+ (run {}))
;; Stop the worker
(worker/stop! +worker+))