Commits

Alvaro Videla  committed 5e8919a

adds fabric script

  • Participants
  • Parent commits 7d46ec6

Comments (0)

Files changed (1)

File src/resizer/fabric.clj

+(ns resizer.fabric
+  (:require [claude.core :as cf]
+            [claude.rabbitmq :as cfrmq]
+            [langohr.exchange :as lhe]
+            [langohr.core :as lhc]))
+
+;; declare exchanges using with-open
+(defn rabbitmq-connect []
+  (if (cf/cloudfoundry?)
+    (lhc/connect (lhc/settings-from (cfrmq/url)))
+    (lhc/connect)))
+
+(defn declare-exchange [ch exchange]
+  (let [{name :name type :type opts :opts} exchange]
+    (lhe/declare ch name type opts)))
+
+(defn init-fabric [exchanges]
+  (let [conn       (rabbitmq-connect)
+        ch         (.createChannel conn)]
+    (map declare-exchange ch exchanges)
+    (.close ch)
+    (.close conn)))