From f2969b12c4da047e81eba66b650353ed81fa2b03 Mon Sep 17 00:00:00 2001 From: Rebecca Graber Date: Wed, 24 Jan 2024 10:47:09 -0500 Subject: [PATCH] feat: add configurable client.id to base settings (#224) --- CHANGELOG.rst | 6 ++++++ edx_event_bus_kafka/__init__.py | 2 +- edx_event_bus_kafka/internal/config.py | 10 +++++++++- edx_event_bus_kafka/internal/tests/test_config.py | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6cf1162d..469f2da4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/edx_event_bus_kafka/__init__.py b/edx_event_bus_kafka/__init__.py index aa636924..256c6965 100644 --- a/edx_event_bus_kafka/__init__.py +++ b/edx_event_bus_kafka/__init__.py @@ -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' diff --git a/edx_event_bus_kafka/internal/config.py b/edx_event_bus_kafka/internal/config.py index 4eea607e..25f6370c 100644 --- a/edx_event_bus_kafka/internal/config.py +++ b/edx_event_bus_kafka/internal/config.py @@ -3,7 +3,6 @@ This module is for internal use only. """ - import warnings from functools import lru_cache from typing import Optional @@ -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 diff --git a/edx_event_bus_kafka/internal/tests/test_config.py b/edx_event_bus_kafka/internal/tests/test_config.py index a80fd786..e0ab6e3d 100644 --- a/edx_event_bus_kafka/internal/tests/test_config.py +++ b/edx_event_bus_kafka/internal/tests/test_config.py @@ -50,6 +50,7 @@ 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', @@ -57,6 +58,7 @@ def test_full(self): 'security.protocol': 'SASL_SSL', 'sasl.username': 'some_other_key', 'sasl.password': 'some_other_secret', + 'client.id': 'my_client_id', }