Use :uri instead of :host/:port as :spec for carmine

clj-a2png
Marcin Kulik 8 years ago
parent 70fd5608f6
commit a3feeb6454

@ -25,8 +25,7 @@
:bucket s3-bucket :bucket s3-bucket
:path-prefix "uploads/"} :path-prefix "uploads/"}
:exp-set :exp-set
{:host redis-host {:uri redis-url}
:port redis-port}
:png-gen :png-gen
{:bin-path a2png-bin-path} {:bin-path a2png-bin-path}
:executor :executor

@ -5,12 +5,12 @@
[com.stuartsierra.component :as component] [com.stuartsierra.component :as component]
[taoensso.carmine :as car])) [taoensso.carmine :as car]))
(defrecord RedisClient [host port] (defrecord RedisClient [uri]
component/Lifecycle component/Lifecycle
(start [component] (start [component]
(if (:listener component) (if (:listener component)
component component
(let [conn {:pool {} :spec {:host host :port port}}] (let [conn {:pool {} :spec {:uri uri}}]
(assoc component :conn conn)))) (assoc component :conn conn))))
(stop [component] (stop [component]
(if (:conn component) (if (:conn component)
@ -24,5 +24,5 @@
(contains? [this value] (contains? [this value]
(car/as-bool (car/wcar (:conn this) (car/exists value))))) (car/as-bool (car/wcar (:conn this) (car/exists value)))))
(defn redis-client [{:keys [host port]}] (defn redis-client [{:keys [uri]}]
(->RedisClient host port)) (->RedisClient uri))

@ -32,8 +32,7 @@
's3-bucket (:s3-bucket env) 's3-bucket (:s3-bucket env)
's3-access-key (:s3-access-key env) 's3-access-key (:s3-access-key env)
's3-secret-key (:s3-secret-key env) 's3-secret-key (:s3-secret-key env)
'redis-host (:redis-host env "localhost") 'redis-url (:redis-url env "redis://localhost")
'redis-port (Integer/parseInt (:redis-port env "6379"))
'a2png-bin-path (:a2png-bin-path env "a2png/a2png.sh")} 'a2png-bin-path (:a2png-bin-path env "a2png/a2png.sh")}
system (->> (load-system [(io/resource "asciinema/system.edn")] bindings) system (->> (load-system [(io/resource "asciinema/system.edn")] bindings)
(component/start))] (component/start))]

Loading…
Cancel
Save