Fork me on GitHub
#core-async
<
2019-10-01
>
jumar09:10:13

I'm thinking how to best approach backpressure handling in the api layer. I'd like to return 202 status code if I can process more request (that is there's still a room in an "incoming requests" channel) and 429 if way too many requests have been submitted and the user has to wait and try again later. What is a good way to approach that? Not sure if there's a way how to check if channel/buffer is full. My first attempt was just to use put! and let it fail after exhausting the internal queue of size 1024 but that's not good (I can't define my own limits and the error reporting is isn't very nice) Now I'm thinking about using offer!, checking its return value and responding with error status code if the return value is nil...

Alex Miller (Clojure team)12:10:51

That’s a good approach

👍 8