Fork me on GitHub
#pedestal
<
2017-05-05
>
hagmonk02:05:14

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

kirill.salykin06:05:22

@hagmonk very curious what you are using it for?

hagmonk10:05:44

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

hagmonk10:05:19

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

hagmonk10:05:57

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.

kirill.salykin10:05:18

indeed, thanks!

hagmonk10:05:55

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))
                     int-fn
                     (update-in [:timings int-nm] #(- (System/currentTimeMillis) %))))]
    (interceptor {::chain/execution-id int-id
                  :name                int-nm
                  :enter               ent-fn})))

crimeminister13:05:26

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.

hagmonk17:05:10

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.

crimeminister13:05:26

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

deg14:05:11

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.

mtnygard14:05:03

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

curtosis21:05:18

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

curtosis21:05:41

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

curtosis22:05:35

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