diff --git a/src/ziggurat/config.clj b/src/ziggurat/config.clj index 6460ef7b..e8f0633b 100644 --- a/src/ziggurat/config.clj +++ b/src/ziggurat/config.clj @@ -8,9 +8,9 @@ (:import (java.util Properties) [org.apache.kafka.common.config SaslConfigs]) (:gen-class - :methods [^{:static true} [get [String] Object] - ^{:static true} [getIn [java.lang.Iterable] Object]] - :name tech.gojek.ziggurat.internal.Config)) + :methods [^{:static true} [get [String] Object] + ^{:static true} [getIn [java.lang.Iterable] Object]] + :name tech.gojek.ziggurat.internal.Config)) (def config-file "config.edn") @@ -25,10 +25,10 @@ :username "guest" :password "guest" :channel-timeout 2000 - :publish-retry {:back-off-ms 5000 - :non-recoverable-exception {:enabled true - :back-off-ms 5000 - :count 5}}} + :publish-retry {:back-off-ms 5000 + :non-recoverable-exception {:enabled true + :back-off-ms 5000 + :count 5}}} :jobs {:instant {:worker-count 4 :prefetch-count 4}} :rabbit-mq {:delay {:queue-name "%s_delay_queue" @@ -77,9 +77,9 @@ (declare config) (defstate config - :start (let [config-values-from-env (config-from-env config-file) - app-name (-> config-values-from-env :ziggurat :app-name)] - (deep-merge (interpolate-config default-config app-name) config-values-from-env))) + :start (let [config-values-from-env (config-from-env config-file) + app-name (-> config-values-from-env :ziggurat :app-name)] + (deep-merge (interpolate-config default-config app-name) config-values-from-env))) (defn ziggurat-config [] (get config :ziggurat)) @@ -169,9 +169,9 @@ (defn- normalize-value [v] (str/trim - (cond - (keyword? v) (name v) - :else (str v)))) + (cond + (keyword? v) (name v) + :else (str v)))) (defn set-property [mapping-table p k v] @@ -195,8 +195,8 @@ (defn- add-jaas-properties [properties jaas-config] (if (some? jaas-config) - (let [username (get jaas-config :username) - password (get jaas-config :password) + (let [username (get jaas-config :username) + password (get jaas-config :password) mechanism (get jaas-config :mechanism)] (doto properties (.put SaslConfigs/SASL_JAAS_CONFIG (create-jaas-properties username password mechanism)))) @@ -222,11 +222,11 @@ :mechanism <>}}} " (let [ssl-configs-enabled (:enabled ssl-config-map) - jaas-config (get ssl-config-map :jaas)] + jaas-config (get ssl-config-map :jaas)] (if (true? ssl-configs-enabled) (as-> properties pr - (add-jaas-properties pr jaas-config) - (reduce-kv set-property-fn pr ssl-config-map)) + (add-jaas-properties pr jaas-config) + (reduce-kv set-property-fn pr ssl-config-map)) properties))) (defn build-properties @@ -249,11 +249,14 @@ " [set-property-fn config-map] (as-> (Properties.) pr - (build-ssl-properties pr set-property-fn (ssl-config)) - (reduce-kv set-property-fn pr config-map))) + (build-ssl-properties pr set-property-fn (ssl-config)) + (reduce-kv set-property-fn pr config-map))) (def build-consumer-config-properties (partial build-properties (partial set-property consumer-config-mapping-table))) (def build-producer-config-properties (partial build-properties (partial set-property producer-config-mapping-table))) (def build-streams-config-properties (partial build-properties (partial set-property streams-config-mapping-table))) + +(defn get-configured-retry-count [] + (-> (ziggurat-config) :retry :count)) diff --git a/src/ziggurat/mapper.clj b/src/ziggurat/mapper.clj index 7aed46fd..7fe928bb 100644 --- a/src/ziggurat/mapper.clj +++ b/src/ziggurat/mapper.clj @@ -1,7 +1,7 @@ (ns ziggurat.mapper (:require [clojure.string :as str] [sentry-clj.async :as sentry] - [ziggurat.config :refer [ziggurat-config]] + [ziggurat.config :refer [ziggurat-config get-configured-retry-count]] [ziggurat.messaging.producer :as producer] [ziggurat.metrics :as metrics] [ziggurat.new-relic :as nr] @@ -39,7 +39,7 @@ failure-metric "failure" dead-letter-metric "dead-letter" multi-message-processing-namespaces [message-processing-namespaces [message-processing-namespace]] - user-payload (create-user-payload message-payload (producer/get-configured-retry-count))] + user-payload (create-user-payload message-payload (get-configured-retry-count))] (clog/with-logging-context {:consumer-group topic-entity-name} (nr/with-tracing "job" new-relic-transaction-name (try diff --git a/src/ziggurat/messaging/producer.clj b/src/ziggurat/messaging/producer.clj index 33fe5f04..d46963f0 100644 --- a/src/ziggurat/messaging/producer.clj +++ b/src/ziggurat/messaging/producer.clj @@ -154,9 +154,6 @@ (defn get-channel-retry-count [topic-entity channel] (:count (channel-retry-config topic-entity channel))) -(defn get-configured-retry-count [] - (-> (ziggurat-config) :retry :count)) - (defn- get-channel-queue-timeout-or-default-timeout [topic-entity channel] (let [channel-queue-timeout-ms (:queue-timeout-ms (channel-retry-config topic-entity channel)) queue-timeout-ms (get-in (rabbitmq-config) [:delay :queue-timeout-ms])] diff --git a/test/ziggurat/mapper_test.clj b/test/ziggurat/mapper_test.clj index 85c3668c..555ed6eb 100644 --- a/test/ziggurat/mapper_test.clj +++ b/test/ziggurat/mapper_test.clj @@ -1,7 +1,7 @@ (ns ziggurat.mapper-test (:require [clojure.test :refer :all] [schema.core :as s] - [ziggurat.config :refer [ziggurat-config]] + [ziggurat.config :refer [ziggurat-config get-configured-retry-count]] [ziggurat.fixtures :as fix] [ziggurat.mapper :refer :all] [ziggurat.messaging.connection :refer [producer-connection]]