-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: [FC-0074] explain how the event bus works and how to use it #426
Conversation
Thanks for the pull request, @mariajgrimaldi! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
1feabc8
to
3954196
Compare
@@ -1,42 +0,0 @@ | |||
Using the Open edX Event bus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add a redirect here?
Should these docs live here? Or on docs.openedx.org? (I don't know the right answer just asking) |
* **Eliminate Expensive, Delayed, Batch Synchronization**: replace expensive batch processing with near real-time data updates. | ||
* **Reduce the need for Plugins**: reduce the computational load for plugins that don't need to run in the same process by allowing cross-service communication of lifecycle events. | ||
|
||
How Does the Open edX Event Bus Work? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also include more detail on how the data is serialized/deserialized? Or is this a good high-level overview?
Either way, I'm writing some documents on adding event bus support to new events so that the serialization/deserialization details can be included there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good for a high level overview. I think it would be nice to put something in here about the differences between the Event Bus and Celery tasks, and when to use each. It's one of the more common questions I get.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I'm going to add a comparison table or something similar about them. Thank you for the suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compared the event bus async communication style with async tasks here: fb51a60. Let me know if this is what you had in mind. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of comments, this is looking great!
Install the Open edX Event Bus Plugin | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
First, you need to install the Open edX Event Bus plugin in both the producing and consuming services. The plugin is a Django app that provides the necessary tools and configurations to produce and consume events. You could install the Redis plugin by running: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a note here about things that go into selecting a backend and why we're using redis here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I added a note about redis being the community supported solution here: 0d3218a
@mariajgrimaldi the more I think about it the more I think leaving the docs here is good! @bmtcril said he'd take a look at these docs for me, since he's more familiar with the event bus. |
@@ -0,0 +1,84 @@ | |||
Using the Open edX Event Bus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bmtcril: I also created a document on how to ensure event bus compatibility for new events, what do you think about merging these two docs into one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they are probably good as they are, don't want to make them too long!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call!
docs/concepts/event-bus.rst
Outdated
|
||
- Service A sends the event as a message to the event bus and continues its execution, as we previously explained. | ||
- Service B polls the message broker for new messages and processes them. | ||
- Service B re-emits the event with the data that was transmitted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think re-emits is a little confusing here, I initially read it as "re-emits the event to the bus". Maybe change it to "locally emits the Django signal of the event..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I improved the wording here: 12e4768
|
||
This is an example of an asynchronous approach (from the producer point of view) to send messages to another services but with a blocking nature. | ||
|
||
Use the Open edX Event bus instead of asynchronous tasks when: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! A thing we don't talk about often, and I'm not sure we should, is that the event bus (especially Kafka) can be used to send event data out of the Open edX ecosystem entirely. Many different databases and products can consume Kafka events for various purposes, for instance Student Information Services or Contact Relationship Managers may listen to enrollment events to update their own state. Do you think it's worth a bullet point here about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a pretty interesting use case we could include here: https://docs.openedx.org/projects/openedx-events/en/latest/reference/real-life-use-cases.html#cross-services-communication. I think it'd give community folks a more rounded view of all that can be done with the event bus, do you have more info on this use case? Although I could use the info in the comment.
For this document purpose, I added some high-level ideas of external services that can consume events sent through the event bus: ee3f8e5
docs/how-tos/using-the-event-bus.rst
Outdated
|
||
First, you need to install the Open edX Event Bus plugin in both the producing and consuming services. The plugin is a Django app that provides the necessary tools and configurations to produce and consume events. You could install the Redis plugin by running: | ||
|
||
.. code-block:: bash | ||
|
||
pip install edx-event-bus-redis | ||
|
||
Configure the Event Bus | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
.. note:: Redis is the community-supported plugin for the Open edX Event Bus and is the recommended plugin to use. You can find more information about the Redis plugin in the `event-bus-redis`_ repository. However, you can also implement your own plugin with your preferred message broker by following the :doc:`../how-tos/add-new-event-bus-concrete-implementation` documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that both redis and kafka are community supported, but redis is just the default. We should mention Kafka as an alternative before doing another implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying, I actually thought it was only Redis. I've changed the note with the suggestion: 1a4bafa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
5777568
to
dc5d29e
Compare
@@ -0,0 +1,87 @@ | |||
Using the Open edX Event Bus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to add more details about this, like console logs, etc, in another PR. Thanks!
Description
This PR adds sections dedicated to the Open edX Event bus technology:
An Overview of the technology:
What is the Open edX Event Bus?
Why use the Open edX Event Bus?
How Does the Open edX Event Bus Work? With an architectural diagram.
How is the Open edX Event Bus Used?
Using the Open edX Event Bus: install event-bus plugins, configure them, produce events, consume events, run the consumer
Event Bus Configurations: the available configurations taken from in-line code annotations.
Glossary terms for the event-bus: event bus, message, message broker, worker, producer, consumer, topic
These docs were written based on the available documentation about the Open edX Event Bus:
https://openedx.atlassian.net/wiki/spaces/AC/pages/3508699151/How+to+start+using+the+Event+Bus
https://openedx.atlassian.net/wiki/spaces/AC/pages/3474784257/Event+Bus+Architecture+Overview
This PR partially addresses #238