ring 2021-11-02

I'm rewriting an app with synchronous handlers to be async, and I don't want to have to rewrite all my endpoint handlers to be async. Is there an async->sync middleware somewhere that I can put at the top of my middleware stack to handle this?

@wombawomba maybe a silly question - but why are you rewriting your app to be async

It's a bit difficult to know which happen before and which happen after the handler without some analysis. If you do know then you can write a "translator"

oh whoops, missed this

I went ahead and wrote an async->sync middleware, which worked

anyway, the idea is to eventually get rid of it and make everything async

the main point in making things async would be to prevent requests from hogging threads

And then the follow up is - the model that lets you work with async code the same as sync code is the interceptor model

Pedestal does this, there might be some library that implements it separately, but that is the way

The other is to try a loom EAP and then see if that does enough for you

Then hope/cope

Because making an async->sync middleware would probably negate whatever benefit you hoped to get from being async otherwise

oh, cool

not sure when that feature will land though?

also, it seems like I'd have to wait for my webserver (Jetty) to support it

It will preview in 18 or 19. Thats March or September.

> A preview feature is a new feature whose design, specification, and implementation are complete, but which is not permanent, which means that the feature may exist in a different form or not at all in future JDK release

and you can already use it with jetty