nats.py icon indicating copy to clipboard operation
nats.py copied to clipboard

Configurable concurrency level for messages processing

Open maruqu opened this issue 5 years ago • 2 comments

I have encountered some limitations of the client, I would like to set how many concurrent tasks can be created simultaneously for the subscription. Currently it can be either one or unlimited (is_async=True).

I found a comment in the client:

# NOTE: Deprecate this usage in a next release,
# the handler implementation ought to decide
# the concurrency level at which the messages
# should be processed.

We can take it a bit further and add ability to configure an exact number of running tasks per subscription. It should relatively easy to implement using asyncio.Semaphore.

What do you think about it? I would be happy to create a PR.

maruqu avatar Nov 21 '19 16:11 maruqu

I think this is a great idea! I was wondering whether we could have a separate library that offers this behavior but having it as part of the client also sounds good

wallyqs avatar Nov 21 '19 19:11 wallyqs

I would love to have concurrency when it comes to messages on a subscription, even unlimited. I can't find the is_async option, though. Is that outdated?

raduitache avatar May 17 '22 07:05 raduitache