Fork me on GitHub
#reitit
<
2020-08-03
>
wombawomba10:08:42

In https://github.com/metosin/reitit/blob/master/doc/ring/compiling_middleware.md, the example middleware returns a fn with two different arities; one on the form [request], and one on the form [request respond raise]. What determines which of these is used? Do I need to implement both, or can I pick one?

ikitommi11:08:20

@wombawomba Ring async uses the 3-arity version. You can call your app with 1 or 3 args, arity is retained through the call chain and it throws ArityError etc. if some component (mw or handler) doesn't support it.

ikitommi11:08:24

web servers like ring-jetty have option to start the server in async mode.

wombawomba11:08:34

Alright, thanks! I’m not familiar with async mode, but I’ll take a look. You wouldn’t happen to know if running Ring in async mode is common/recommended?

ikitommi11:08:19

mostly not needed. reitit-http should be run in async mode as any step/interceptor can return promise, async channel etc. running it in stnc-mode causes all those to block.

ikitommi11:08:09

if you use jdbc-pooling, it's anyway blocking the thread. The async-db libs are not that great in clj.

ikitommi11:08:00

metosin/porsas is so pre-alpha 🐖

wombawomba11:08:43

Cool, thanks for the info 🙂

ikitommi14:08:30

someone asked about #malli get-in walking over :and schemas. About to close a PR which will add utilities for doing that and much more. Getting closer to release.