Source

resizer / src / resizer / fabric.clj

Full commit
(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)))