Use cases for the queue in interceptors?

We enqueue interceptors in our pedestal app in order to perform side effects. So if an interceptor wants to write to Datomic it enqueues an interceptor for that, same for sending an email.

In contrast to the approach outlined in http://pedestal.io/reference/interceptors with a database-interceptor that’s always part of the chain, we enqueue the effectful interceptor, so we can know if a side effect was performed successfully (leave is called) or errored (error is called) and to ensure ordering (e.g. write to db first, send email only if that succeeded).

We also built Nextjournal’s code execution using pedestal’s interceptor chain. When a user presses run to execute a code cell, we look at the request and the current state and enqueue interceptors that do the necessary work (pull docker image, boot runtime, execute dependent cells etc). This is nice because it allows us to test this planning step without having to perform actual side effects.

3 Likes