Mixing Async and Sync handlers in ring?

So I’m looking to add an async handler to our compojure routes for server sent events. However, from what I can tell I can’t do this without making all our handlers async. Ideally I just want to make this one handler async.

How do people normally approach this problem? Thanks.

What webserver are you using?
Usually you need to change only the middlewares that modify the response. For Aleph there is – aleph-middleware

There is a similar discussion going on in #aleph

And another comment regarding mixing sync / async ring handlers. A solution would be to use Reitit Interceptors.

1 Like

I’m just using ring (jetty) as the web server. But when I change :async? to true:

(jetty/run-jetty app {:port port :join? false :async? true})

Then none of my sync routes work. I don’t even know if it’s possible to have both sync and async handlers on the same jetty server (so I might be asking for the impossible here :sweat_smile:).

EDIT: I’m using compojure for routing

Did anyone make some performance tests on the sync vs async?

The easiest solution for me was just to migrate our project to aleph. Which amazingly just worked without having to change any of the existing end points. :slight_smile:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.