Hi all,

I'm curious about the options for managing APIs in Clojure code in a 
relatively idiomatic / consistent / functional way. The features I'm 
roughly interested in are:
- ability to "wrap" a remote API in a regular Clojure function
- abstraction away from the details of how the API is implemented (REST, 
SOAP etc.)
- sane handling for both async and synchronous calls (ideally building on 
core.async)
- possible serialisation of API references (e.g. you can send an API 
function to another machine that can then call it)
- sane default handling for standard stuff like timeouts, errors etc?

I'm thinking of syntax roughly like:

(defapi foo 
  :call (fn [x] (do-rest-call "http://some.host/api/foo"; x other-param))
  :timeout 1000
  :async true
  :on-error (fn [ex] (handle-exception ex)))
=> [an API object, probably a defrecord-like structure that implements IFn] 

(foo "hello")
=> core.asyc channel that returns result of calling foo API

((sync foo) "hello")
=> result of synchronously calling foo API

(async? foo)
=> true

((modify foo {:timeout 100}) "quick hello")
=> like (foo "hello") but with a shorter timeout


Has anyone built or seen anything like this? 
If not, would this be a useful library / contrib?

-- 
-- 
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/groups/opt_out.

Reply via email to