From 33835bdce3a9ac8155b22a7aa87b7979384397d6 Mon Sep 17 00:00:00 2001 From: Marco Marini Date: Wed, 15 May 2024 14:17:52 +0200 Subject: [PATCH] slightly better config --- resources/config.edn | 15 ++------------- src/weller/config.clj | 27 +++++++++++++++++++++++++-- src/weller/event_handler.clj | 10 ++-------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/resources/config.edn b/resources/config.edn index 491de06..65f3560 100644 --- a/resources/config.edn +++ b/resources/config.edn @@ -1,13 +1,2 @@ -{:alfresco {:scheme "http" - :host "localhost" - :port 8080 - :core-path "alfresco/api/-default-/public/alfresco/versions/1" - :search-path "alfresco/api/-default-/public/search/versions/1" - :auth-path "alfresco/api/-default-/public/authentication/versions/1" - :discovery-path "alfresco/api/discovery" - :user "admin" - :password "admin"} - :activemq {:scheme "tcp" - :host "localhost" - :port 61616 - :topic "alfresco.repo.event2"}} \ No newline at end of file +{:alfresco {:scheme "http" + :port 8080}} \ No newline at end of file diff --git a/src/weller/config.clj b/src/weller/config.clj index a861e21..11466fd 100644 --- a/src/weller/config.clj +++ b/src/weller/config.clj @@ -14,6 +14,29 @@ ; You should have received a copy of the GNU General Public License ; along with this program. If not, see . -(ns weller.config) +(ns weller.config + (:require [immuconf.config :as immu] + [taoensso.telemere :as t])) -(def config (atom {})) \ No newline at end of file +(def config (atom {:alfresco {:scheme "http" + :host "localhost" + :port 8080 + :core-path "alfresco/api/-default-/public/alfresco/versions/1" + :search-path "alfresco/api/-default-/public/search/versions/1" + :auth-path "alfresco/api/-default-/public/authentication/versions/1" + :discovery-path "alfresco/api/discovery" + :user "admin" + :password "admin"} + :activemq {:scheme "tcp" + :host "localhost" + :port 61616 + :topic "alfresco.repo.event2"}})) + +(defn configure + [] + (try + (let [cfg (immu/load "resources/config.edn")] + (swap! config assoc :alfresco (merge (:alfresco @config) (:alfresco cfg))) + (swap! config assoc :activemq (merge (:activemq @config) (:activemq cfg)))) + (catch Exception e (t/log! :error (.getMessage e)))) + (t/log! :debug @config)) \ No newline at end of file diff --git a/src/weller/event_handler.clj b/src/weller/event_handler.clj index f2161d2..f1fc098 100644 --- a/src/weller/event_handler.clj +++ b/src/weller/event_handler.clj @@ -43,14 +43,8 @@ (defn make-handler ([] - ;; load config - (try - (let [config (immu/load "resources/config.edn")] - (swap! c/config assoc :activemq (:activemq config)) - (swap! c/config assoc :alfresco (:alfresco config))) - (catch Exception e (t/log! :error (.getMessage e)))) - (t/log! :debug @c/config) - + ;; load configuration + (c/configure) (let [chan (a/chan)] (map->EventHandler {:listener (activemq/make-listener (:activemq @c/config) chan) :taps []