diff --git a/src/ziggurat/init.clj b/src/ziggurat/init.clj index 14c816e8..e56738b7 100644 --- a/src/ziggurat/init.clj +++ b/src/ziggurat/init.clj @@ -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 @@ -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) @@ -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 @@ -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)) diff --git a/test/ziggurat/init_test.clj b/test/ziggurat/init_test.clj index b9d2b8fc..67ebdbaa 100644 --- a/test/ziggurat/init_test.clj +++ b/test/ziggurat/init_test.clj @@ -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)