Skip to content

Commit

Permalink
docs: improve docstrings for handlers and new events routers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Oct 31, 2023
1 parent 29e8faa commit db5a97f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
5 changes: 4 additions & 1 deletion event_routing_backends/backends/async_events_router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""
Generic async router to send events to hosts via celery.
Events router to send events to hosts via celery.
This events router will trigger a celery task to send the events to the
configured hosts.
"""
from event_routing_backends.backends.events_router import EventsRouter
from event_routing_backends.tasks import dispatch_bulk_events, dispatch_event, dispatch_event_persistent
Expand Down
1 change: 0 additions & 1 deletion event_routing_backends/backends/events_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def __init__(self, processors=None, backend_name=None):
Arguments:
processors (list): list of processor instances
backend_name (str): name of the router backend
sync (bool): whether to send events synchronously or in celery tasks
"""
self.processors = processors if processors else []
self.backend_name = backend_name
Expand Down
8 changes: 6 additions & 2 deletions event_routing_backends/backends/sync_events_router.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
"""
Generic router to send events to hosts.
Events router to send events to hosts in sync mode.
This router is expected to be used with the event bus, which
can be configured to use this router to send events to hosts
in the same thread as it process the events.
"""
from event_routing_backends.backends.events_router import EventsRouter
from event_routing_backends.tasks import bulk_send_events, send_event


class SyncEventsRouter(EventsRouter):
"""
Router to send events to hosts via celery using requests library.
Router to send events to hosts using requests library.
"""

def dispatch_event(self, event_name, updated_event, router_type, host_configurations):
Expand Down
12 changes: 12 additions & 0 deletions event_routing_backends/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ def send_tracking_log_to_backends(
): # pylint: disable=unused-argument
"""
Listen for the TRACKING_LOG_EVENT_EMITTED signal and send the event to the enabled backends.
The process is the following:
1. Unserialize the tracking log from the signal.
2. Get the tracker instance to get the enabled backends (mongo, event_bus, logger, etc).
3. Get the event bus backends as those are the interested in the signals and multiple can be configured.
4. Process the event with the event bus backend.
5. Send the processed event to the different event bus backends configured. Any event bus backend can be configured
with multiples backends (xAPI or Caliper).
This allows us to only send the tracking log to the event bus once and then the event bus will send it to the
different configured backends.
"""
tracking_log = kwargs.get("tracking_log")

Expand Down
2 changes: 0 additions & 2 deletions event_routing_backends/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def plugin_settings(settings):
'edx.course.grade.passed.first_time'
]

settings.EVENT_TRACKING_BACKENDS_EVENT_BUS_ENABLED = True

settings.WHITELIST_EVENTS = {
'xapi': [
'edx.course.enrollment.activated',
Expand Down

0 comments on commit db5a97f

Please sign in to comment.