Fork me on GitHub

@crimeminister I've started using pedestal interceptors for non-web stuff and I'd certainly find that useful


@hagmonk very curious what you are using it for?


@kirill.salykin basically I have a data processing pipeline, so I now set that up as a chain of interceptors


which allows me to specify the steps using data, and do other things like wrap the interceptors in metrics and logging


so I actually have each interceptor wrapped in another one that times step execution, adding that to the context map as we go. Very handy.


indeed, thanks!


I made a function that takes a symbol (which points to a function) and turns it into an interceptor:

(defn make-interceptor [sym]
  (let [int-fn (deref sym)
        int-nm (-> sym str (str/split #"/") last keyword)
        int-id (uuid/v1)
        ent-fn (fn [ctx]
                 (-> ctx
                     (assoc-in [:timings int-nm] (System/currentTimeMillis))
                     (update-in [:timings int-nm] #(- (System/currentTimeMillis) %))))]
    (interceptor {::chain/execution-id int-id
                  :name                int-nm
                  :enter               ent-fn})))


hagmonk: I will use this, thanks. Makes me want a nice way for evaluating pipeline performance more generally, e.g. an easy way to run criterium on every interceptor fn and on the pipeline as a whole.


Yeah! I think there's a ton of stuff you can do. For instance I'm trying to spec the context map as it goes, so this make-interceptor can be subjected to generative testing. Having a generative test that runs across my whole pipeline would be kind of mind blowing, and could be interesting for performance testing too.


@hagmonk I have been using Onyx with its onyx-local-rt for setting up data processing pipelines, but I like the idea of the Pedestal interceptor chain becoming more of a first class citizen. It will be easier to embed, for one thing.


In Vase, why is it required to give a :name to each interceptor in the service edn file? It seems that this often just adds noise that I don't directly care about.


Paul has just cut a release of Vase. 0.9.1 is on Clojars, along with an update of the template project.


any tips on where to look for why an interceptor crashes with a stack overflow?


or, perhaps better, how to trap it so it doesn’t overflow the stack?


hrm.. turns out it wasn’t directly an interceptor problem, but still not sure why pedestal was dumping a massive overflowing stack trace.