Skip to content

Commit b90a274

Browse files
committed
fix scaffolding
1 parent f5bb851 commit b90a274

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

clojure/wheel/resources/config.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
:bearer-token "top-secret!"}}
2121
:cron-jobs [{:type :allocate-order
2222
:channel-id "UA"
23-
:expression "4 0 * ? * * *"}]}}
23+
:expression "0 0/1 * 1/1 * ? *"}]}}

clojure/wheel/src/wheel/infra/cron/core.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212
(defn init []
1313
(for [cron-job-config (config/get-all-cron-jobs)]
14-
(job/schedule scheduler cron-job-config)))
14+
(job/schedule scheduler cron-job-config)))

clojure/wheel/src/wheel/infra/cron/job/core.clj

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(defmulti jobtype :type)
1010

1111
(defn- identifier [{:keys [channel-id type]}]
12-
(keyword channel-id (name type)))
12+
(str channel-id "/" (name type)))
1313

1414
(defn- create-job [channel-config cron-job-config]
1515
(qj/build
@@ -22,22 +22,20 @@
2222
:as cron-job-config}]
2323
(qt/build
2424
(qt/with-identity (qt/key (identifier cron-job-config)))
25-
(qt/start-now)
2625
(qt/with-schedule (qsc/schedule
2726
(qsc/cron-schedule expression)))))
2827

29-
(defn create [{:keys [channel-id]
30-
:as cron-job-config}]
31-
(when-let [channel-config (config/get-channel-config channel-id)]
32-
(create-job channel-config cron-job-config)))
33-
3428
(defn handle [channel-fn ctx]
35-
(channel-fn (qc/from-job-data ctx) nil))
29+
(let [{:strs [channel-config cron-job-config]} (qc/from-job-data ctx)]
30+
(channel-fn (:channel-id cron-job-config) channel-config)))
3631

37-
(defn schedule [scheduler cron-job-config]
38-
(when-let [job (create cron-job-config)]
39-
(qs/schedule scheduler job (create-trigger cron-job-config))))
32+
(defn schedule [scheduler {:keys [channel-id]
33+
:as cron-job-config}]
34+
(when-let [channel-config (config/get-channel-config channel-id)]
35+
(let [job (create-job channel-config cron-job-config)
36+
trigger (create-trigger cron-job-config)]
37+
(qs/schedule scheduler job trigger))))
4038

4139
(comment
42-
(key {:channel-id "UA"
43-
:type :allocate-order}))
40+
(identifier {:channel-id "UA"
41+
:type :allocate-order}))

clojure/wheel/src/wheel/marketplace/channel.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
(s/def ::name #{:tata-cliq :amazon :flipkart})
66

77
(defmulti allocate-order (fn [channel-id channel-config]
8-
(:name channel-config)))
8+
(:channel-name channel-config)))

clojure/wheel/src/wheel/marketplace/tata_cliq/core.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
(catch Throwable ex
2424
(event/processing-failed ex id :ranging channel-id channel-name))))
2525

26-
(defmethod channel/allocate-order :tata-cliq [x _]
27-
(prn "~~>" x))
26+
(defmethod channel/allocate-order :tata-cliq [channel-id channel-config]
27+
(prn channel-id "~~>" channel-config))

0 commit comments

Comments
 (0)