rabbitmq / rabbitmq-cli

Command line tools for RabbitMQ
Other
105 stars 34 forks source link

Per user connection and channel limits CLI #429

Closed Ayanda-D closed 4 years ago

Ayanda-D commented 4 years ago

Proposed Changes

The following is an implementation of setting/clearing channel limits for a specific user.

1. Set max-connections and max-channels

rabbitmqctl set_user_limits username '{"max-connections": 50, "max-channels": 500}'
rabbitmqctl set_user_limits username '{"max-connections": 50}'
rabbitmqctl set_user_limits username '{"max-channels": 500}'

2. Set max-connections and max-channels to zero: block connection/channel creation

rabbitmqctl set_user_limits username '{"max-connections": 0}'
rabbitmqctl set_user_limits username '{"max-channels": 0}'

3. Set max-connections and max-channels to a negative: clearing limits

rabbitmqctl set_user_limits username '{"max-connections": -1}'
rabbitmqctl set_user_limits username '{"max-channels": -1}'

4. Clear max-connections or max-channels for a user

rabbitmqctl clear_user_limits username 'max-connections'
rabbitmqctl clear_user_limits username 'max-channels'

5. Clear all limits for a user

rabbitmqctl clear_user_limits username 'all'

Part of: https://github.com/rabbitmq/rabbitmq-server/pull/2380

This work has be carried out by Erlang Solutions and sponsored by CloudAMQP

Types of Changes

What types of changes does your code introduce to this project? Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask on the mailing list. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further Comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc.

michaelklishin commented 4 years ago

@Ayanda-D thank you, this is a solid starting point. I had to tweak some tests but functionally-wise, what is merged is no different from your contribution. We will assess this feature some more and decide when to backport it to v3.8.x.

michaelklishin commented 4 years ago

This has been merged manually with a merge commit. Keep this in mind when backporting.

michaelklishin commented 4 years ago

Backported to v3.8.x.