Hi,


I like to introduce you to sv.system (
https://github.com/SimpleValue/sv.system) another component library for 
Clojure. There are many great libraries out there to implement 
component-based Clojure systems, so why should you care about sv.system. If 
I had to pick one reason it would be: sv.system makes it straightforward to 
leverage conventions.

Conventions could provide people with great leverage ("advantage for 
accomplishing a purpose" 
<http://www.etymonline.com/index.php?search=leverage>). For example 
probably every Clojure web developer knows that you find the HTTP status 
code under the :status key in a Ring response map.


A sv.system example:


(use 'sv.system.core)
(use 'org.httpkit.server)

(defn start [ring-handler opts]
  (run-server
   ring-handler
   opts))

(defn stop [stop-httpkit]
  (stop-httpkit))

(defn httpkit-server []
  {:binds [:httpkit :server]
   :start [start [:ring :handler] {:port 3000}]
   :stop stop})

(defn hello-handler [name request]
  {:status 200
   :body (str "Hello " name)
   :content-type "text/plain"})

(defn ring-handler []
  {:binds [:ring :handler]
   :start [partial #'hello-handler "World"]})

(defonce system
  (start-system #{(ring-handler) (httpkit-server)}))

;; (stop-system system)


The example starts a httpkit server on http://localhost:3000/ that returns 
"Hello World" as response. Take a look at 
https://github.com/SimpleValue/sv.system to read about the details. The 
example uses the convention that you find the main Ring handler of the 
application under [:ring :handler]. For sure this convention is not 
established. But you can imagine that it could help to orientate yourself, 
when you are joining an existing Clojure project that uses a common set of 
vocabulary for the different components of a typical Clojure system.


I hope you find sv.system useful and I would appreciate your feedback.


Best regards


Max

-- 
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