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

feat: adds requirements and settings for the redis event bus #4

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tutorevent_bus_redis/patches/openedx-common-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# redis connection url
# https://redis.readthedocs.io/en/stable/examples/ssl_connection_examples.html#Connecting-to-a-Redis-instance-via-a-URL-string
EVENT_BUS_REDIS_CONNECTION_URL = "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{
REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/"
EVENT_BUS_TOPIC_PREFIX = "{{ EVENT_BUS_REDIS_TOPIC_PREFIX }}"
EVENT_BUS_PRODUCER = "{{ EVENT_BUS_REDIS_PRODUCER }}"
EVENT_BUS_CONSUMER = "{{ EVENT_BUS_REDIS_CONSUMER }}"
{% if EVENT_BUS_REDIS_CONSUMER_CONSECUTIVE_ERRORS_LIMIT %}
EVENT_BUS_REDIS_CONSUMER_CONSECUTIVE_ERRORS_LIMIT = int("{{ EVENT_BUS_REDIS_CONSUMER_CONSECUTIVE_ERRORS_LIMIT }}")
{% endif %}
EVENT_BUS_REDIS_CONSUMER_POLL_TIMEOUT = int("{{ EVENT_BUS_REDIS_CONSUMER_POLL_TIMEOUT }}")
EVENT_BUS_REDIS_STREAM_MAX_LEN = int("{{ EVENT_BUS_REDIS_STREAM_MAX_LEN }}")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
edx-event-bus-redis=={{ EVENT_BUS_REDIS_RELEASE }}
27 changes: 27 additions & 0 deletions tutorevent_bus_redis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@
# Each new setting is a pair: (setting_name, default_value).
# Prefix your setting names with 'EVENT_BUS_REDIS_'.
("EVENT_BUS_REDIS_VERSION", __version__),

# Version of https://github.com/openedx/event-bus-redis to install
# TODO: support forks
("EVENT_BUS_REDIS_RELEASE", "0.3.2"),

# Prefix for topics sent over the event bus
("EVENT_BUS_REDIS_TOPIC_PREFIX", "openedx"),

# Producer class which can send events to redis streams.
("EVENT_BUS_REDIS_PRODUCER", "edx_event_bus_redis.create_producer"),

# Consumer class which can consume events from redis streams.
("EVENT_BUS_REDIS_CONSUMER", "edx_event_bus_redis.RedisEventConsumer"),

# If the consumer encounters this many consecutive errors, exit with an error. This is intended to be used in a
# context where a management system (such as Kubernetes) will relaunch the consumer automatically.
# Default is "None", which means the consumer will never relaunch.
("EVENT_BUS_REDIS_CONSUMER_CONSECUTIVE_ERRORS_LIMIT", 0),

# How long the consumer should wait for new entries in a stream.
# As we are running the consumer in a while True loop, changing this setting doesn't make much difference expect
# for changing number of monitoring messages while waiting for new events.
# https://redis.io/commands/xread/#blocking-for-data
("EVENT_BUS_REDIS_CONSUMER_POLL_TIMEOUT", 60),

# Limits stream size to approximately this number
("EVENT_BUS_REDIS_STREAM_MAX_LEN", 10_000),
]
)

Expand Down