Skip to content

Commit

Permalink
feat: add configurable client.id to base settings (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Graber authored Jan 24, 2024
1 parent d3fdbbb commit f2969b1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Change Log
Unreleased
**********

[5.6.0] - 2024-01-24
********************
Changed
=======
* Added configurable client.id to base configuration

[5.5.0] - 2023-09-21
********************
Changed
Expand Down
2 changes: 1 addition & 1 deletion edx_event_bus_kafka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
from edx_event_bus_kafka.internal.consumer import KafkaEventConsumer
from edx_event_bus_kafka.internal.producer import KafkaEventProducer, create_producer

__version__ = '5.5.0'
__version__ = '5.6.0'
10 changes: 9 additions & 1 deletion edx_event_bus_kafka/internal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
This module is for internal use only.
"""

import warnings
from functools import lru_cache
from typing import Optional
Expand Down Expand Up @@ -110,6 +109,15 @@ def load_common_settings() -> Optional[dict]:
'sasl.password': secret,
})

# .. setting_name: EVENT_BUS_KAFKA_CLIENT_ID
# .. setting_default: None
# .. setting_description: Identifier for the producing/consuming application. Useful for debugging. If not set
# .. Kafka will use 'rdkafka' as the identifier
client_id = getattr(settings, 'EVENT_BUS_APP_NAME', None)
if client_id:
base_settings.update({
'client.id': client_id
})
return base_settings


Expand Down
2 changes: 2 additions & 0 deletions edx_event_bus_kafka/internal/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ def test_full(self):
EVENT_BUS_KAFKA_BOOTSTRAP_SERVERS='localhost:54321',
EVENT_BUS_KAFKA_API_KEY='some_other_key',
EVENT_BUS_KAFKA_API_SECRET='some_other_secret',
EVENT_BUS_APP_NAME='my_client_id',
):
assert config.load_common_settings() == {
'bootstrap.servers': 'localhost:54321',
'sasl.mechanism': 'PLAIN',
'security.protocol': 'SASL_SSL',
'sasl.username': 'some_other_key',
'sasl.password': 'some_other_secret',
'client.id': 'my_client_id',
}


Expand Down

0 comments on commit f2969b1

Please sign in to comment.