Fork me on GitHub
#ring
<
2021-11-02
>
wombawomba12:11:16

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?

Ben Sless05:11:36

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"

emccue23:11:24

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

emccue19:11:42

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

emccue19:11:30

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

emccue19:11:19

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

emccue19:11:10

Then hope/cope

emccue19:11:12

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

wombawomba14:11:25

oh whoops, missed this

wombawomba14:11:41

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

wombawomba14:11:02

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

wombawomba14:11:34

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

wombawomba14:11:48

not sure when that feature will land though?

wombawomba14:11:00

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

emccue14:11:24

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

emccue14:11:31

> 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

emccue14:11:36

and you can already use it with jetty