Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
feat: Add a default consumer for login
Browse files Browse the repository at this point in the history
  • Loading branch information
bmtcril committed Feb 13, 2024
1 parent a600a97 commit 9f2086a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
20 changes: 20 additions & 0 deletions tutorevent_bus_redis/patches/local-docker-compose-services
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,23 @@ kafka-control-center:
CONFLUENT_METRICS_TOPIC_REPLICATION: 1
PORT: 9021
{% endif %}

{% if EVENT_BUS_BACKEND %}
# This is just a stub test for showing how we could run consumers
login-consumer:
image: docker.io/overhangio/openedx:17.0.1-nightly
environment:
SERVICE_VARIANT: lms
DJANGO_SETTINGS_MODULE: lms.envs.tutor.production
command: >
./manage.py lms consume_events -t user-login -g user-activity-service {% if EVENT_BUS_BACKEND == "redis" %}--extra '{"consumer_name": "user-login-1"}'{% endif %}
restart: unless-stopped
volumes:
- ../apps/openedx/settings/lms:/openedx/edx-platform/lms/envs/tutor:ro
- ../apps/openedx/settings/cms:/openedx/edx-platform/cms/envs/tutor:ro
- ../apps/openedx/config:/openedx/config:ro
- ../../data/lms:/openedx/data
- ../../data/openedx-media:/openedx/media
depends_on:
- {% if EVENT_BUS_BACKEND == "redis" %}redis{% elif EVENT_BUS_BACKEND == "kafka" %}kafka{% endif %}
{% endif %}
Empty file.
38 changes: 19 additions & 19 deletions tutorevent_bus_redis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@
########################################
# CONFIGURATION
########################################
# FIXME: Update this to a saner config structure less likely to break, and able
# to activate and deactivate individual events more easily.
PRODUCER_CONFIG = """{
'org.openedx.content_authoring.xblock.published.v1': {
'content-authoring-xblock-lifecycle':
{'event_key_field': 'xblock_info.usage_key', 'enabled': False},
'content-authoring-xblock-published':
{'event_key_field': 'xblock_info.usage_key', 'enabled': False},
},
'org.openedx.content_authoring.xblock.deleted.v1': {
'content-authoring-xblock-lifecycle':
{'event_key_field': 'xblock_info.usage_key', 'enabled': False},
},
'org.openedx.learning.auth.session.login.completed.v1': {
'user-login': {'event_key_field': 'user.pii.username', 'enabled': True},
},
}
"""

hooks.Filters.CONFIG_DEFAULTS.add_items(
[
Expand All @@ -37,25 +55,7 @@
"confluent_kafka[avro,schema-registry]",
],
),

# These are a subset of known events, there are many more.
# FIXME: Update this to a saner config structure less likely to break
("EVENT_BUS_PRODUCER_CONFIG", """{
'org.openedx.content_authoring.xblock.published.v1': {
'content-authoring-xblock-lifecycle':
{'event_key_field': 'xblock_info.usage_key', 'enabled': False},
'content-authoring-xblock-published':
{'event_key_field': 'xblock_info.usage_key', 'enabled': False},
},
'org.openedx.content_authoring.xblock.deleted.v1': {
'content-authoring-xblock-lifecycle':
{'event_key_field': 'xblock_info.usage_key', 'enabled': False},
},
'org.openedx.learning.auth.session.login.completed.v1': {
'user-login': {'event_key_field': 'user.pii.username', 'enabled': True},
},
}
"""),
("EVENT_BUS_PRODUCER_CONFIG", PRODUCER_CONFIG),

######################################
# redis backend settings
Expand Down

0 comments on commit 9f2086a

Please sign in to comment.