In a web-app you probably want the thread safety an atom provides, so it 
would be a good choice.

You can include a reference to your atom in your system config if you want 
to retain the reloaded-like / dependency injection pattern:

(def changing-config (atom {}))

;; system-map
(def sys-map
 {:a "a"
  :b 42
  :c changing-config})

(defn my-handler
 [handler sys-map]
 (fn [req] {:status 200 :body @(:c sys-map)}))


On Saturday, May 28, 2016 at 2:16:32 PM UTC-4, babysnakes wrote:
>
> Hey all,
>
> I don't have a lot of experience with clojure but I did write a few small 
> services in clojure. Until now the state of the services I wrote were 
> static so I constructed a system map (more or less following Stuart 
> Sierra's reloaded workflow - without using the component framework) and 
> injected it to the various handlers via middleware closure. This works 
> great when the state is static. Now I have to write a small service where 
> the state should be updated (I have to periodically pull new 
> configurations). The first place I can think of to put this state is in a 
> global atom, but I was wondering if there's a pattern that allows me to 
> dynamically update global state without using global atom.
>
> Thanks in advance
>
> Haim
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to