core-async

jumar 2019-10-01T09:19:13.024600Z

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...

alexmiller 2019-10-01T12:28:51.025Z

That’s a good approach

👍 2