Skip to content
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] add more detailed concepts on events #406

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

mariajgrimaldi
Copy link
Member

@mariajgrimaldi mariajgrimaldi commented Oct 11, 2024

Description

This PR improves the concept section of the documentation by adding a new document dedicated only to Open edX Events.

Initially, I also added two additional modifications:

  1. Update references in the Hooks Extension Framework document and explain why the framework should be adopted.
  2. Adding a new document comparing Open edX Events vs Filters to ease adoption.

Which I later dropped in favor of centralizing shared documentation docs.openedx.org and avoiding duplication across repos: So I'll be moving those docs to docs.openedx.org, Here's the PR for the implementation: openedx/docs.openedx.org#599

For more details on the decision, please see this thread.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 11, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 11, 2024

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If 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 @openedx/hooks-extension-framework. Tag them in a comment and let them know that your changes are ready for review.

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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@mariajgrimaldi mariajgrimaldi changed the title Mjg/improve concepts docs docs: add more detailed documentation under the concepts section Oct 11, 2024
@mariajgrimaldi mariajgrimaldi marked this pull request as ready for review October 15, 2024 10:50
@mariajgrimaldi mariajgrimaldi requested a review from a team as a code owner October 15, 2024 10:50
@mariajgrimaldi mariajgrimaldi marked this pull request as draft October 15, 2024 12:17
@mariajgrimaldi mariajgrimaldi removed the request for review from a team October 15, 2024 12:17
docs/concepts/events-vs-filters.rst Outdated Show resolved Hide resolved
docs/concepts/events-vs-filters.rst Outdated Show resolved Hide resolved
docs/concepts/events-vs-filters.rst Outdated Show resolved Hide resolved
@mariajgrimaldi
Copy link
Member Author

mariajgrimaldi commented Oct 28, 2024

@sarina @Apgomeznext: here's the WIP I've been working on for the 1.1 Improve Definitions and Update Outdated References in the Framework project feature.

I discussed with AnaP having feedback loops within the maintenance team about the documents' content. She'd get involved to review the document structure once she has the capacity for the project. So, early feedback is welcome.

@mariajgrimaldi mariajgrimaldi changed the title docs: add more detailed documentation under the concepts section docs: [FC-0074] add more detailed docs under the concepts section Oct 28, 2024
@mariajgrimaldi mariajgrimaldi changed the title docs: [FC-0074] add more detailed docs under the concepts section docs: [FC-0074] add detailed concepts on events (what, how, why) Oct 28, 2024
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Oct 30, 2024
@mariajgrimaldi mariajgrimaldi marked this pull request as ready for review November 4, 2024 13:17
@mariajgrimaldi mariajgrimaldi changed the title docs: [FC-0074] add detailed concepts on events (what, how, why) docs: [FC-0074] add detailed concepts on events Nov 4, 2024
@mariajgrimaldi mariajgrimaldi requested review from a team and sarina November 4, 2024 16:17
@mariajgrimaldi mariajgrimaldi changed the title docs: [FC-0074] add detailed concepts on events docs: [FC-0074] add more detailed concepts on events Nov 4, 2024

Django includes a “signal dispatcher” which helps decoupled applications get notified when actions occur elsewhere in the framework. In a nutshell, signals allow certain senders to notify a set of receivers that some action has taken place. They’re especially useful when many pieces of code may be interested in the same events.

Events are primarily used as a communication method between components within the same application process or with external services using the Event Bus technology, making them the standard communication mechanism within the Open edX ecosystem.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe have "Event Bus" link to documentation on the event bus?

Copy link
Member Author

@mariajgrimaldi mariajgrimaldi Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: 6926b20#diff-982f9d143e6afcea5b84eeb1ea3c3fb5412239c1968359fab161cb4af58e9b63R62

But the only available docs we have to date about the event bus is a confluence document, so that's what I linked: https://openedx.atlassian.net/wiki/spaces/AC/pages/3508699151/How+to+start+using+the+Event+Bus. Once we move those documents here, I'll update the references.


The event execution process follows these steps:

1. An application component emits an event by calling the ``send_event`` method implemented by ``OpenEdxPublicEvents``, which calls the Django signal ``send`` method under the hood.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. An application component emits an event by calling the ``send_event`` method implemented by ``OpenEdxPublicEvents``, which calls the Django signal ``send`` method under the hood.
#. An Open edX application component emits an event by calling the ``send_event`` method implemented by ``OpenEdxPublicEvents``, which calls the Django signal ``send`` method under the hood.

Using #. will auto-make a numbered list in rST. You need to include a blank line after each bullet point.

Copy link
Member Author

@mariajgrimaldi mariajgrimaldi Nov 4, 2024

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 already applied the change: 6926b20#diff-982f9d143e6afcea5b84eeb1ea3c3fb5412239c1968359fab161cb4af58e9b63R32-R47


1. An application component emits an event by calling the ``send_event`` method implemented by ``OpenEdxPublicEvents``, which calls the Django signal ``send`` method under the hood.
2. The class generates Open edX-specific metadata for the event on the fly, like the event version or the timestamp when the event was sent. The event receivers use this metadata during their processing.
3. We call the ``send`` method from Django signals, which allows us to use the same Django signals registry for receiver management.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is "we"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1. An application component emits an event by calling the ``send_event`` method implemented by ``OpenEdxPublicEvents``, which calls the Django signal ``send`` method under the hood.
2. The class generates Open edX-specific metadata for the event on the fly, like the event version or the timestamp when the event was sent. The event receivers use this metadata during their processing.
3. We call the ``send`` method from Django signals, which allows us to use the same Django signals registry for receiver management.
4. The event receivers registered by the Django signals registry mechanism for the emitted event are executed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean to register an event receiver? Maybe link to documentation on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion. I added a reference to how to listen to signals in Django: 6926b20#diff-982f9d143e6afcea5b84eeb1ea3c3fb5412239c1968359fab161cb4af58e9b63R63

docs/concepts/openedx-events.rst Outdated Show resolved Hide resolved
docs/concepts/openedx-events.rst Outdated Show resolved Hide resolved
Here is an example of an event in action:

1. A user enrolls in a course, `triggering the COURSE_ENROLLMENT_CREATED event`_. This event includes information about the user, course, and enrollment details.
2. A `signal receiver listening`_ for the ``COURSE_ENROLLMENT_CREATED`` event is called and processes the event data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link is a little confusing, because the text is generic but you're referencing a specific handler. How about:

Suggested change
2. A `signal receiver listening`_ for the ``COURSE_ENROLLMENT_CREATED`` event is called and processes the event data.
#. A signal receiver listening for the ``COURSE_ENROLLMENT_CREATED`` event is called and processes the event data. In this case, it would be the `course_enrollment_post_save receiver`_.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thank you!

5. Each event receivers performs additional processing or triggers other actions based on the event data.
6. The event is considered complete once all registered signal receivers have executed.

Here is an example of an event in action:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Here is an example of an event in action:
Here is an example of an event that triggers email in response to course enrollment in action:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the step by step with a more accurate description, could you review it again?

1. A user enrolls in a course, `triggering the COURSE_ENROLLMENT_CREATED event`_. This event includes information about the user, course, and enrollment details.
2. A `signal receiver listening`_ for the ``COURSE_ENROLLMENT_CREATED`` event is called and processes the event data.
3. The signal receiver sends a notification to the user's email confirming their enrollment in the course.
4. The event is considered complete once the signal receiver has finished processing the event.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there code or something that "considers" the event complete? I guess I don't know exactly what this means.

Copy link
Member Author

@mariajgrimaldi mariajgrimaldi Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this. I meant something like:

The event processing is complete once all signal receivers have finished executing, so the application continues its execution...

But that sounds way more complex than it actually is, so I changed it: 6926b20#diff-982f9d143e6afcea5b84eeb1ea3c3fb5412239c1968359fab161cb4af58e9b63R37

How are Open edX Events used?
-----------------------------

Developers can create receivers for Open edX Events by implementing Django signal receivers that respond to these events emitted by the Open edX platform. These signal receivers can be registered using Django's signal mechanism, allowing them to listen for events and execute custom logic in response.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to include some detail about how you don't need to modify code within the openedx github org to achieve this. Could we link out to some third-party examples?

Copy link
Member Author

@mariajgrimaldi mariajgrimaldi Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely! I'm currently working on a list of use cases. In the next few hours, I'll link the PR here in this comment.

I'll link the PR here in this comment tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U
Projects
Status: Waiting on Author
Development

Successfully merging this pull request may close these issues.

4 participants