>
> I can't emphasize enough the utility of the interceptor chain pattern, as 
> employed heavily in pedestal.
>

Interesting... Its almost like a workflow framework, but for simpler in 
code workflows. I'm reluctant to have a dependency on pedestal just for 
this though.

On Sunday, 1 October 2017 21:00:31 UTC-7, Luke Burton wrote:
>
>
> On Sep 30, 2017, at 3:14 PM, Didier <did...@gmail.com <javascript:>> 
> wrote:
>
> Is there another way to execute a set of complex steps which does not rely 
> on let and can be try/catched in the manner I describe?
>
>
> I can't emphasize enough the utility of the interceptor chain pattern, as 
> employed heavily in pedestal.
>
> I use this *everywhere* now. I have code that interleaves interceptors 
> into a chain to augment them with timing information, audit logs, and more. 
> I have written code that maps a subset of an interceptor chain over a 
> cluster of machines, then reduces the results back down locally. Most 
> importantly, they are fantastically useful when it comes time to debug a 
> complex business process … you can swap interceptors in and out easily, 
> isolate stateful interceptors to enable better mocking during tests, and 
> more.
>
> Here's a basic application of interceptors. It's really not much code 
> considering what you get. This doesn't even scratch the surface of what 
> they can do.
>
> (ns interceptor.test
>   (:require
>     [io.pedestal.interceptor.chain :as chain]))
>
> (def step1
>   {:name  :step1
>    :enter (fn [ctx]
>             (let [x "sheep"]
>               (assoc ctx :result x)))})
>
> (def step2
>   {:name  :step2
>    :error (fn [ctx ex-info]
>             (println "so much for step2:" (:exception-type (ex-data 
> ex-info))))
>    :enter (fn [{:keys [result] :as ctx}]
>             
>             (println "time to transform" result "into a number")
>             (update ctx :result #(Long/parseLong %)))})
>
> (defn run []
>   (chain/execute {} [step1 step2]))
>
>
>

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