Hi,

Currently, I am in the process of writing a client to server API which is 
not trivial to consume.  In particular it needs a 3-step authentication 
process: login with user name and password, get an authentication token, 
open a session with the token and finally consume the API with the 
session.  Sessions and tokens can expire and the client should handle that 
transparently: if it has a token, create a new session, if the token 
expired and it has username and password, create a new token...  So, 
sessions and tokens would have to be local, mutable, encapsulated state, as 
far as I can see.

Now; I wonder how to best model this in Clojure.

My favorite right now is, creating a closure over a local atom and return 
it to the user.  The downside to this is that it feels unnatural to consume 
different parts of the API, e.g. (client :do-something &args) vs (client 
:do-something-else & other-args).  It would be nice to defined a protocol 
with function do-something and do-something-else but then I would have to 
pass the atom as an argument to the record which feels even worse.

Am I missing an obvious other solution? Have you done something similar, 
how?

Any pointers welcome.


Best regards,
stefan

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