Skip to content

Commit

Permalink
feat: add event_metadata parameter to EventBusProducer send API (#152)
Browse files Browse the repository at this point in the history
Will be used to add CloudEvent headers to all events
  • Loading branch information
Rebecca Graber authored Dec 1, 2022
1 parent e3e7166 commit ada0249
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
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
----------

[3.2.0] - 2022-11-30
--------------------
Changed
~~~~~~~
* Add event_metadata parameter to EventBusProducer send API. **Note:** Calling this method with the new argument will throw an exception with older versions of this library that don't yet support the parameter.

[3.1.0] - 2022-11-22
--------------------
Added
Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "3.1.0"
__version__ = "3.2.0"
5 changes: 5 additions & 0 deletions openedx_events/event_bus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from django.test.signals import setting_changed
from django.utils.module_loading import import_string

from openedx_events.data import EventsMetadata
from openedx_events.tooling import OpenEdxPublicSignal


Expand Down Expand Up @@ -67,9 +68,11 @@ class EventBusProducer(ABC):
Parent class for event bus producer implementations.
"""

# TODO: Make event_metadata required (https://github.com/openedx/openedx-events/issues/153)
@abstractmethod
def send(
self, *, signal: OpenEdxPublicSignal, topic: str, event_key_field: str, event_data: dict,
event_metadata: EventsMetadata = None
) -> None:
"""
Send a signal event to the event bus under the specified topic.
Expand All @@ -80,6 +83,7 @@ def send(
event_key_field: Path to the event data field to use as the event key (period-delimited
string naming the dictionary keys to descend)
event_data: The event data (kwargs) sent to the signal
event_metadata: (optional) The CloudEvent metadata
"""


Expand All @@ -90,6 +94,7 @@ class NoEventBusProducer(EventBusProducer):

def send(
self, *, signal: OpenEdxPublicSignal, topic: str, event_key_field: str, event_data: dict,
event_metadata: EventsMetadata = None,
) -> None:
"""Do nothing."""

Expand Down

0 comments on commit ada0249

Please sign in to comment.