Skip to content

Commit

Permalink
feat: add event bus backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Jun 8, 2023
1 parent c6b86c3 commit 9cd48de
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 26 deletions.
28 changes: 28 additions & 0 deletions eventtracking/backends/event_bus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Event tracker backend that emits events to the event-bus."""
from openedx_events.analytics.signals import TRACKING_EVENT_EMITTED
from openedx_events.analytics.data import TrackingLogData

class EventBusRoutingBackend:
"""
Event tracker backend that emits an Open edX public signal.
"""

def __init__(self, **kwargs):
"""
Event tracker backend that emits an Open edX public signal.
"""

def send(self, event):
"""
Emit the TRACKING_EVENT_EMITTED Open edX public signal to allow
other apps to listen for tracking events.
"""
# .. event_implemented_name: TRACKING_EVENT_EMITTED
TRACKING_EVENT_EMITTED.send_event(
tracking_log=TrackingLogData(
name=event.get('name'),
timestamp=event.get('timestamp'),
data=event.get('data'),
context=event.get('context')
)
)
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pytz
six
celery
edx-django-utils
openedx_events
43 changes: 34 additions & 9 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ amqp==5.1.1
# via kombu
asgiref==3.7.2
# via django
billiard==3.6.4.0
attrs==23.1.0
# via openedx-events
backports-zoneinfo[tzdata]==0.2.1
# via
# celery
# kombu
billiard==4.1.0
# via celery
celery==5.2.7
celery==5.3.0
# via
# -c requirements/constraints.txt
# -r requirements/base.in
Expand All @@ -35,16 +41,23 @@ django==3.2.19
# -r requirements/base.in
# django-crum
# edx-django-utils
# openedx-events
django-crum==0.7.9
# via edx-django-utils
django-waffle==3.0.0
# via edx-django-utils
edx-django-utils==5.4.0
edx-django-utils==5.5.0
# via -r requirements/base.in
kombu==5.2.4
edx-opaque-keys[django]==2.3.0
# via openedx-events
fastavro==1.7.4
# via openedx-events
kombu==5.3.0
# via celery
newrelic==8.8.0
# via edx-django-utils
openedx-events==8.0.1
# via -r requirements/base.in
pbr==5.11.1
# via stevedore
prompt-toolkit==3.0.38
Expand All @@ -54,24 +67,36 @@ psutil==5.9.5
pycparser==2.21
# via cffi
pymongo==3.13.0
# via -r requirements/base.in
# via
# -r requirements/base.in
# edx-opaque-keys
pynacl==1.5.0
# via edx-django-utils
python-dateutil==2.8.2
# via celery
pytz==2023.3
# via
# -r requirements/base.in
# celery
# django
six==1.16.0
# via
# -r requirements/base.in
# click-repl
# python-dateutil
sqlparse==0.4.4
# via django
stevedore==5.1.0
# via edx-django-utils
typing-extensions==4.6.2
# via asgiref
# via
# edx-django-utils
# edx-opaque-keys
typing-extensions==4.6.3
# via
# asgiref
# kombu
tzdata==2023.3
# via
# backports-zoneinfo
# celery
vine==5.0.0
# via
# amqp
Expand Down
6 changes: 3 additions & 3 deletions requirements/celery52.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
amqp==5.1.1
billiard==3.6.4.0
celery==5.2.7
billiard==4.1.0
celery==5.3.0
click==8.1.3
click-didyoumean==0.3.0
click-repl==0.2.0
kombu==5.2.4
kombu==5.3.0
prompt-toolkit==3.0.38
vine==5.0.0
51 changes: 42 additions & 9 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,26 @@ astroid==2.15.5
# -r requirements/test.txt
# pylint
# pylint-celery
attrs==23.1.0
# via
# -r requirements/test.txt
# openedx-events
babel==2.12.1
# via sphinx
billiard==3.6.4.0
backports-zoneinfo[tzdata]==0.2.1
# via
# -r requirements/test.txt
# celery
# kombu
billiard==4.1.0
# via
# -r requirements/test.txt
# celery
build==0.10.0
# via
# -r requirements/pip-tools.txt
# pip-tools
celery==5.2.7
celery==5.3.0
# via
# -c requirements/constraints.txt
# -r requirements/test.txt
Expand Down Expand Up @@ -95,6 +104,7 @@ django==3.2.19
# -r requirements/test.txt
# django-crum
# edx-django-utils
# openedx-events
django-crum==0.7.9
# via
# -r requirements/test.txt
Expand All @@ -105,16 +115,24 @@ django-waffle==3.0.0
# edx-django-utils
docutils==0.19
# via sphinx
edx-django-utils==5.4.0
edx-django-utils==5.5.0
# via -r requirements/test.txt
edx-lint==5.3.4
# via
# -r requirements/dev.in
# -r requirements/test.txt
edx-opaque-keys[django]==2.3.0
# via
# -r requirements/test.txt
# openedx-events
exceptiongroup==1.1.1
# via
# -r requirements/test.txt
# pytest
fastavro==1.7.4
# via
# -r requirements/test.txt
# openedx-events
filelock==3.12.0
# via
# -r requirements/ci.txt
Expand All @@ -139,15 +157,15 @@ jinja2==3.1.2
# -r requirements/test.txt
# code-annotations
# sphinx
kombu==5.2.4
kombu==5.3.0
# via
# -r requirements/test.txt
# celery
lazy-object-proxy==1.9.0
# via
# -r requirements/test.txt
# astroid
markupsafe==2.1.2
markupsafe==2.1.3
# via
# -r requirements/test.txt
# jinja2
Expand All @@ -161,6 +179,8 @@ newrelic==8.8.0
# via
# -r requirements/test.txt
# edx-django-utils
openedx-events==8.0.1
# via -r requirements/test.txt
packaging==23.1
# via
# -r requirements/ci.txt
Expand Down Expand Up @@ -233,7 +253,9 @@ pylint-plugin-utils==0.8.2
# pylint-celery
# pylint-django
pymongo==3.13.0
# via -r requirements/test.txt
# via
# -r requirements/test.txt
# edx-opaque-keys
pynacl==1.5.0
# via
# -r requirements/test.txt
Expand All @@ -248,6 +270,10 @@ pytest==7.3.1
# pytest-cov
pytest-cov==4.1.0
# via -r requirements/test.txt
python-dateutil==2.8.2
# via
# -r requirements/test.txt
# celery
python-slugify==8.0.1
# via
# -r requirements/test.txt
Expand All @@ -256,7 +282,6 @@ pytz==2023.3
# via
# -r requirements/test.txt
# babel
# celery
# django
pyyaml==6.0
# via
Expand All @@ -270,6 +295,7 @@ six==1.16.0
# -r requirements/test.txt
# click-repl
# edx-lint
# python-dateutil
# tox
snowballstemmer==2.2.0
# via sphinx
Expand Down Expand Up @@ -298,6 +324,7 @@ stevedore==5.1.0
# -r requirements/test.txt
# code-annotations
# edx-django-utils
# edx-opaque-keys
text-unidecode==1.3
# via
# -r requirements/test.txt
Expand Down Expand Up @@ -325,13 +352,19 @@ tox==3.28.0
# tox-battery
tox-battery==0.6.1
# via -r requirements/ci.txt
typing-extensions==4.6.2
typing-extensions==4.6.3
# via
# -r requirements/test.txt
# asgiref
# astroid
# kombu
# pylint
urllib3==2.0.2
tzdata==2023.3
# via
# -r requirements/test.txt
# backports-zoneinfo
# celery
urllib3==2.0.3
# via requests
vine==5.0.0
# via
Expand Down
Loading

0 comments on commit 9cd48de

Please sign in to comment.