From e8df0782c3de42cd77679d6251e3ccdb64a9481b Mon Sep 17 00:00:00 2001 From: Rebecca Graber Date: Thu, 25 Jan 2024 11:29:57 -0500 Subject: [PATCH] fix: use new method for setting client id (#225) --- CHANGELOG.rst | 4 ++-- edx_event_bus_kafka/internal/config.py | 7 ++----- edx_event_bus_kafka/internal/tests/test_config.py | 4 ++-- requirements/base.in | 4 ++-- requirements/base.txt | 2 +- requirements/dev.txt | 2 +- requirements/doc.txt | 2 +- requirements/quality.txt | 2 +- requirements/test.txt | 2 +- 9 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 469f2da..3c9fd16 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,11 +14,11 @@ Change Log Unreleased ********** -[5.6.0] - 2024-01-24 +[5.6.0] - 2024-01-25 ******************** Changed ======= -* Added configurable client.id to base configuration +* Added client.id to base configuration. [5.5.0] - 2023-09-21 ******************** diff --git a/edx_event_bus_kafka/internal/config.py b/edx_event_bus_kafka/internal/config.py index 25f6370..ca9a9a5 100644 --- a/edx_event_bus_kafka/internal/config.py +++ b/edx_event_bus_kafka/internal/config.py @@ -10,6 +10,7 @@ from django.conf import settings from django.dispatch import receiver from django.test.signals import setting_changed +from openedx_events.data import get_service_name # See https://github.com/openedx/event-bus-kafka/blob/main/docs/decisions/0005-optional-import-of-confluent-kafka.rst try: @@ -109,11 +110,7 @@ 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) + client_id = get_service_name() if client_id: base_settings.update({ 'client.id': client_id diff --git a/edx_event_bus_kafka/internal/tests/test_config.py b/edx_event_bus_kafka/internal/tests/test_config.py index e0ab6e3..780794c 100644 --- a/edx_event_bus_kafka/internal/tests/test_config.py +++ b/edx_event_bus_kafka/internal/tests/test_config.py @@ -50,7 +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', + EVENTS_SERVICE_NAME='my_service', ): assert config.load_common_settings() == { 'bootstrap.servers': 'localhost:54321', @@ -58,7 +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', + 'client.id': 'my_service', } diff --git a/requirements/base.in b/requirements/base.in index 181af2b..6b6252d 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -2,7 +2,7 @@ -c constraints.txt Django # Web application framework -# openedx-events 8.5.0 adds serialization methods to EventsMetadata -openedx-events>=8.5.0 # Events API +# openedx-events 9.3.0 adds get_service_name method +openedx-events>=9.3.0 # Events API edx_django_utils edx_toggles diff --git a/requirements/base.txt b/requirements/base.txt index c1746ba..3ab5cac 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -49,7 +49,7 @@ markupsafe==2.1.4 # via jinja2 newrelic==9.5.0 # via edx-django-utils -openedx-events==9.2.0 +openedx-events==9.3.0 # via -r requirements/base.in pbr==6.0.0 # via stevedore diff --git a/requirements/dev.txt b/requirements/dev.txt index 1c045aa..b9027d7 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -218,7 +218,7 @@ nh3==0.2.15 # via # -r requirements/quality.txt # readme-renderer -openedx-events==9.2.0 +openedx-events==9.3.0 # via -r requirements/quality.txt packaging==23.2 # via diff --git a/requirements/doc.txt b/requirements/doc.txt index a6fcd1a..b24bd36 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -158,7 +158,7 @@ newrelic==9.5.0 # edx-django-utils nh3==0.2.15 # via readme-renderer -openedx-events==9.2.0 +openedx-events==9.3.0 # via -r requirements/test.txt packaging==23.2 # via diff --git a/requirements/quality.txt b/requirements/quality.txt index f1fff8d..91afdb9 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -153,7 +153,7 @@ newrelic==9.5.0 # edx-django-utils nh3==0.2.15 # via readme-renderer -openedx-events==9.2.0 +openedx-events==9.3.0 # via -r requirements/test.txt packaging==23.2 # via diff --git a/requirements/test.txt b/requirements/test.txt index 93a3b81..0a19d93 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -92,7 +92,7 @@ newrelic==9.5.0 # via # -r requirements/base.txt # edx-django-utils -openedx-events==9.2.0 +openedx-events==9.3.0 # via -r requirements/base.txt packaging==23.2 # via pytest