-
Notifications
You must be signed in to change notification settings - Fork 59
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] centralize docs for the hooks extension framework #599
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9510dc8
docs: centralize docs for the hooks extension framework
mariajgrimaldi 992a204
refactor: address PR suggestions
mariajgrimaldi de07849
fix: use correct org for repos urls
mariajgrimaldi d4db2c4
refactor: change list for subheading
mariajgrimaldi 45c8c38
refactor: improve wording
mariajgrimaldi a88af4d
refactor: use headings according repo standards
mariajgrimaldi c953566
refactor: address PR reviews
mariajgrimaldi 26fc5a7
fix: comment reference to real life use cases
mariajgrimaldi ac72d43
docs: capitalize headings
mariajgrimaldi 970122d
refactor: address PR review
mariajgrimaldi 1b11b25
docs: add references to events/filters use-case list
mariajgrimaldi 6219400
docs: add reference to what's new and concepts card
mariajgrimaldi 55ca20a
fix: use reference instead of references
mariajgrimaldi 01008a0
fix: use correct folder for what's new and concepts card
mariajgrimaldi 06ae46f
docs: address PR reviews
mariajgrimaldi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
source/developers/concepts/hooks_extension_framework.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
Hooks Extension Framework | ||
######################### | ||
|
||
What is the Hooks Extension Framework? | ||
************************************** | ||
|
||
Based on the :doc:`edx-platform:concepts/extension_points`, this framework aims to extend the Open edX platform in a maintainable way without modifying its core. The main goal is to leverage the existing extension capabilities provided by the `Open edX Django plugins`_ architecture, allowing developers to implement new features while reducing the need for core modifications and minimizing maintenance efforts. | ||
|
||
Hooks are places in the Open edX platform where externally defined functions can take place. These functions may alter what the user sees or experiences on the platform, while in other cases, they are informative only. All hooks are designed to be used along with `Open edX Django plugins`_. | ||
|
||
Hooks can be of two types: events and filters. Events are signals sent in specific places whose receivers can extend functionality, while filters are functions that can modify the application's behavior. To allow extension developers to use these definitions in their implementations, both kinds of hooks are defined in lightweight external libraries: | ||
|
||
* `openedx-filters`_ | ||
* `openedx-events`_ | ||
|
||
The framework's main goal is to empower developers to change the platform's functionality as needed while allowing them to migrate to newer Open edX releases with little to no development effort. The framework is designed with stability in mind, meaning it is versioned and backward compatible as much as possible. | ||
|
||
A longer description of the framework and its history can be found in :doc:`openedx-proposals:architectural-decisions/oep-0050-hooks-extension-framework`. | ||
|
||
Why Adopt the Hooks Extension Framework? | ||
**************************************** | ||
|
||
Stable and Maintainable Extensions | ||
================================== | ||
|
||
The Hooks Extension Framework allows developers to extend the platform's functionality in a stable, maintainable, and decoupled way ensuring easier upgrades and long-term stability by removing the need to modify the core in a significant way. | ||
|
||
Contained Solution Implementation | ||
================================= | ||
|
||
By avoiding core modifications, the framework promotes self-contained solutions, eliminating the need for custom code to coexist with core logic which lowers maintenance costs for extension developers. As most extensions can now be implementing using the framework, forks are closer to the core and easier to manage. | ||
|
||
Leveraging the Open edX Plugin Extension Mechanism | ||
================================================== | ||
|
||
The framework allows developers to implement custom business logic and integrations directly in plugins. This keeps core modifications minimal, focusing maintenance and development efforts on plugins, where solutions can be built and maintained independently of the core platform. | ||
|
||
Standardization | ||
=============== | ||
|
||
Both filters and events implement approaches for adding additional features, such as communication between services or backend flow control. With these standards in place, it's easy to identify when and how to use the framework as a solution, ensuring a consistent and predictable approach to extending the platform. | ||
|
||
Community Compatibility | ||
======================= | ||
|
||
The framework allows for shorter and more agile contribution cycles. By adding standardized extension points, contributors avoid creating customer-specific logic, making development more community-friendly. | ||
|
||
Backward Compatibility | ||
====================== | ||
|
||
Hooks are designed to be backwards compatible, guaranteeing stability across releases and making it easier to upgrade without breaking existing functionality. This ensures that extensions built on the framework will continue to work as expected across different Open edX versions. See the Architectural Decision Records (ADRs) about versioning for Open edX Events and Filters for more information: | ||
|
||
* :doc:`openedx-events:decisions/0002-events-naming-and-versioning` | ||
* :doc:`openedx-filters:decisions/0004-filters-naming-and-versioning` | ||
|
||
Open edX Events and Filters | ||
*************************** | ||
|
||
Open edX Events | ||
=============== | ||
|
||
Events are Open edX-specific Django signals sent in specific places on the Open edX platform. Developers write code that listens to these signals and performs additional processing based on the event data. | ||
|
||
To start using Open edX Events in your project, see the :doc:`Open edX Events <openedx-events:index>` documentation. | ||
|
||
Open edX Filters | ||
================ | ||
|
||
Filters are functions that can modify the application's behavior by altering input data or halting execution based on specific conditions. They allow developers to implement application flow control based on their business logic or requirements without directly modifying the application code. | ||
|
||
To start using Open edX Filters in your project, see the :doc:`Open edX Filters <openedx-filters:index>` documentation. | ||
|
||
Differences Between Events and Filters | ||
======================================= | ||
|
||
Here are some key differences between Open edX Events and Filters: | ||
|
||
+--------------------+------------------------------------------------------------------------+-------------------------------------------------------------+ | ||
| | Events | Filters | | ||
+====================+========================================================================+=============================================================+ | ||
| **Purpose** | Notify when an action occurs in a specific part of the | Alter the application flow control. | | ||
| | application. | | | ||
+--------------------+------------------------------------------------------------------------+-------------------------------------------------------------+ | ||
| **Usage** | Used to **extend** functionality via signal receivers when an event is | Used to intercept and **modify** the data used within a | | ||
| | triggered. | component without directly modifying the application | | ||
| | | itself. | | ||
+--------------------+------------------------------------------------------------------------+-------------------------------------------------------------+ | ||
| **Definition** | Defined using the ``OpenEdxPublicSignal`` class, which | Defined using the ``OpenEdxPublicFilter`` class, | | ||
| | provides a structured way to define the data and | which provides a way to define the filter function | | ||
| | metadata associated with the event. | and the parameters it should receive. | | ||
+--------------------+------------------------------------------------------------------------+-------------------------------------------------------------+ | ||
| **Implementation** | Implemented using `Django signals`_, which allow | Implemented using an accumulative pipeline mechanism which | | ||
| | developers to send and receive notifications that an action happened | takes a set of arguments and returns a modified set | | ||
| | within a Django application. | to the caller or raises exceptions during | | ||
| | | processing. | | ||
+--------------------+------------------------------------------------------------------------+-------------------------------------------------------------+ | ||
| **Use cases** | Send an email notification when a user enrolls in a course. | Prevent the enrollment of non-authorized users. | | ||
+--------------------+------------------------------------------------------------------------+-------------------------------------------------------------+ | ||
|
||
How to Know When to Use an Event or a Filter? | ||
============================================= | ||
|
||
When to Use an Open edX Event? | ||
------------------------------ | ||
|
||
A developer might use an Open edX Event in order to perform the following actions. Note that this is not an exhaustive list. | ||
|
||
- Trigger custom logic or processing in response to specific actions within the platform, e.g., updating a search index after a course block is modified. | ||
- Communicate, synchronize, or coordinate with other components or services based on specific events or actions, e.g., send certificate data from LMS to credentials service to keep models up to date. | ||
- Integrate with external systems or services based on specific events or actions, e.g., send user data to third-party services upon registration for marketing purposes. | ||
|
||
Fore more detailed use cases, please visit :doc:`openedx-events:reference/real-life-use-cases`. | ||
|
||
In summary, events can be used to integrate application components with each other or with external services, allowing them to communicate, synchronize, and perform additional actions when specific triggers occur. | ||
|
||
You can review the :doc:`Open edX Events <openedx-events:index>` documentation for more information on :doc:`openedx-events:how-tos/using-events` in your project. This documentation includes a list of :doc:`openedx-events:reference/events` and much more. | ||
|
||
When to Use an Open edX Filter? | ||
------------------------------- | ||
|
||
A developer might use an Open edX Filter in order to perform the following actions. Note that this is not an exhaustive list. | ||
|
||
- Enrich the data or parameters used to a specific component, e.g., fetch reusable LTI configurations from external plugins. | ||
- Enforce specific constraints or business rules of a specific component, e.g., don't allow registration for non-authorized email domains. | ||
- Implement additional features or behavior in a specific component, e.g., add registration extra fields to the user registration form. | ||
|
||
Fore more detailed use cases, please visit :doc:`openedx-filters:reference/real-life-use-cases`. | ||
|
||
In summary, filters can be used when implementing application flow control that modifies the application's behavior, navigation, or user interaction flow during runtime. | ||
|
||
You can review the :doc:`Open edX Filters <openedx-filters:index>` documentation for more information on :doc:`openedx-filters:how-tos/using-filters` in your project. This documentation includes a list of :doc:`openedx-filters:reference/filters` and much more. | ||
|
||
.. _Open edX Django plugins: https://edx.readthedocs.io/projects/edx-django-utils/en/latest/plugins/readme.html | ||
.. _openedx-filters: https://github.com/openedx/openedx-filters | ||
.. _openedx-events: https://github.com/openedx/openedx-events | ||
.. _Django signals: https://docs.djangoproject.com/en/4.2/topics/signals/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,6 +24,7 @@ Open edX Developers | |||||
|
||||||
* :doc:`references/running_pr_tests` | ||||||
* :doc:`references/internal_data_formats/index` | ||||||
* :doc: `contents/hooks_extension_framework` | ||||||
|
||||||
.. grid-item-card:: How-tos | ||||||
:class-card: sd-shadow-md sd-p-2 | ||||||
|
@@ -46,6 +47,7 @@ Open edX Developers | |||||
* :doc:`concepts/platform_overview` | ||||||
* :doc:`concepts/backend_layout_and_approach` | ||||||
* :doc:`concepts/accessibility` | ||||||
* :doc: `contents/hooks_extension_framework` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
+++ | ||||||
.. button-ref:: concepts/index | ||||||
:color: primary | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Yes, I'm realizing I did this all wrong. I'll let you know once it's done.