Fork me on GitHub
#aleph
<
2019-11-19
>
wcalderipe03:11:31

Following up with the async and sync discussion. I still couldn't figure this out so maybe a good soul in the community would post something about it. I'm sure this isn't the first time this issue is bring to the light. I created a repository with the problem scenario: I'm back working in the issue and I created a repository with the scenario.. https://github.com/wcalderipe/lab-compojure-aleph-sync-and-async/blob/master/src/lab_compojure_aleph_async/core.clj

ikitommi05:11:10

@wcalderipe you app should either be fully (sync) ring or async-ring (3 arity). In your example, line41, you define it as sync (1 arity). I don't think you can mix them in ring. Interceptor-model allows you to do it.

wcalderipe06:11:02

Thanks for taking a look on it 🙌 basically this is my original questions "can sync and async handlers coexist in ring?" and you might have answered it. Also, after you mentioned the interceptor model, I quickly found a good article about it, thanks! https://lispcast.com/a-model-of-interceptors/

ikitommi06:11:37

an easy comparison: • with middleware: https://github.com/metosin/reitit/blob/master/examples/ring-swagger/src/example/server.clj • with interceptors: https://github.com/metosin/reitit/blob/master/examples/http-swagger/src/example/server.clj … the latter has one route returning a async value, a Manifold Deferred. All others all sync.

wcalderipe06:11:22

Thanks for sharing it!

pithyless08:11:40

More interceptor docs: http://pedestal.io/reference/interceptors Although it was really this Cognicast podcast that first introduced me to the reasoning behind Pedestal's interceptors and how they can be useful in modeling flow (outside of HTTP): http://blog.cognitect.com/cognicast-transcripts/118

pithyless08:11:14

I never really used Pedestal for anything, but I sure am happy that Paul deGrandis introduced me to the interceptor pattern. And it's nice that with things like metosin/sieppari I can use them without importing pedestal.

wcalderipe22:11:10

Thanks for sharing @U05476190 I'll definitely listen to it today