Skip to content

Commit

Permalink
moves set-properties-for-structured-logging inside initialize-config
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhang.balkundi committed Sep 2, 2021
1 parent 5a9faee commit d6af6f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/ziggurat/init.clj
Expand Up @@ -136,7 +136,8 @@
((fnk (get valid-modes-fns mode)) args)))))

(defn initialize-config []
(start* #{#'config/config}))
(start* #{#'config/config})
(set-properties-for-structured-logging))

(defn start-common-states []
(start* #{#'metrics/statsd-reporter
Expand Down Expand Up @@ -194,9 +195,9 @@
(defn- validate-routes-against-config
([routes route-type]
(doseq [[topic-entity handler-map] routes]
(let [route-config (-> (ziggurat-config)
(get-in [route-type topic-entity]))
channels (-> handler-map (dissoc :handler-fn) (keys) (set))
(let [route-config (-> (ziggurat-config)
(get-in [route-type topic-entity]))
channels (-> handler-map (dissoc :handler-fn) (keys) (set))
config-channels (-> (ziggurat-config)
(get-in [route-type topic-entity :channels])
(keys)
Expand All @@ -216,7 +217,7 @@
(validate-routes-against-config batch-routes :batch-routes)))

(defn- derive-modes [stream-routes batch-routes actor-routes]
(let [base-modes [:management-api :worker]]
(let [base-modes [:management-api :worker]]
(if (and (nil? stream-routes) (nil? batch-routes))
(throw (IllegalArgumentException. "Either :stream-routes or :batch-routes should be present in init args")))
(cond-> base-modes
Expand Down Expand Up @@ -253,7 +254,6 @@
(try
(let [derived-modes (validate-modes modes stream-routes batch-routes actor-routes)]
(initialize-config)
(set-properties-for-structured-logging)
(validate-routes stream-routes batch-routes derived-modes)
(add-shutdown-hook stop-fn derived-modes)
(start start-fn stream-routes batch-routes actor-routes derived-modes))
Expand Down
2 changes: 1 addition & 1 deletion test/ziggurat/init_test.clj
Expand Up @@ -114,8 +114,8 @@
expected-stream-routes {:default {:handler-fn #(constantly nil)}}
config config/default-config]
(with-redefs [init/add-shutdown-hook (fn [_ _] (constantly nil))
config/config-file "config.test.edn"
config/ziggurat-config (fn [] (assoc config :log-format "json"))
init/initialize-config (constantly nil)
init/validate-routes-against-config (constantly nil)
init/start (fn [_ stream-router _ _ _]
(swap! start-was-called not)
Expand Down

0 comments on commit d6af6f1

Please sign in to comment.