This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-07
Channels
- # aws (2)
- # bangalore-clj (4)
- # beginners (62)
- # boot (74)
- # cider (408)
- # cljsrn (17)
- # clojure (117)
- # clojure-dusseldorf (1)
- # clojure-russia (21)
- # clojure-spec (17)
- # clojure-uk (15)
- # clojurescript (154)
- # cursive (3)
- # datomic (16)
- # emacs (33)
- # funcool (3)
- # hoplon (99)
- # off-topic (7)
- # om (10)
- # overtone (3)
- # portland-or (1)
- # protorepl (9)
- # re-frame (83)
- # reagent (11)
- # remote-jobs (1)
- # ring-swagger (24)
- # specter (10)
- # untangled (1)
- # yada (11)
This is not really yada related but probably people here can give some advice anyways: I’m building pipeline system and want to add something like interceptors (in contrast to with-db-conn
macros and similar) that inject stuff into the pipeline’s context.
One thing I’m wondering is how error handling is implemented with interceptors. E.g. an interceptor takes a resource from a pool. How do I make sure it’s returned on failure (or marked as broken)?
One option I can think of is an inteceptor impl like this:
(defprotocol Intercept
(before [this ctx])
(after [this ctx])
(error [this ctx exception]))
but I haven’t ever implemented a system like this so I’m looking for someone who has and may be able to give feedbackI guess Pedestal’s interceptor impl is worth looking at: https://github.com/pedestal/pedestal/blob/master/interceptor/src/io/pedestal/interceptor/chain.clj
@martinklepsch is this perhaps something that could be addressed using manifold’s error mechanism ?
I don’t need async right now, more interested in using it to add “do before” “do after” stuff to my pipeline
so yeah, in your interceptor protocol impl, i would just try to model the try / catch / finally mechanism, which has proven to be powerful 🙂
@lmergen how do you mean model try/catch/finally
so, in your example, it would become
(defprotocol Intercept
(before [this ctx])
(after [this ctx])
(catch [this ctx exception])
(finally [this ctx]))
Ah, I see what you mean, that makes sense, thanks!