Skip to content

Commit

Permalink
Add posibility to define default quotas on user && client (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryarnyah authored Mar 30, 2023
1 parent bb7fff8 commit 846cc6d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ Here some examples on how to use this library:
- name: Ensure quota for user test and test2
kafka_quotas:
entries:
# Applied on default-user
- entity:
user: '<default>'
quotas:
producer_byte_rate: 1044050
consumer_byte_rate: 1044050
request_percentage: 65
# Applied on default-client
- entity:
client: '<default>'
quotas:
producer_byte_rate: 1044050
consumer_byte_rate: 1044050
request_percentage: 65
- entity:
user: test
quotas:
Expand Down
4 changes: 4 additions & 0 deletions module_utils/kafka_lib_quotas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@
maybe_clean_zk_ssl_files
)

DEFAULT_ENTITY = '<default>'


def _map_entity(entity):
e = []
if 'user' in entity and entity['user']:
e.append({
'entity_type': 'user',
'entity_name': entity['user']
if entity['user'] != DEFAULT_ENTITY else None
})
if 'client' in entity and entity['client']:
e.append({
'entity_type': 'client-id',
'entity_name': entity['client']
if entity['client'] != DEFAULT_ENTITY else None
})
return e

Expand Down

0 comments on commit 846cc6d

Please sign in to comment.