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

New Event Semantic and Major Improvements #12

Merged
merged 33 commits into from
Apr 9, 2024

Conversation

mdapena
Copy link
Owner

@mdapena mdapena commented Apr 9, 2024

Initial Checks

  • The code compiles successfully without any errors or warnings.
  • I have personally tested these changes on my local environment.
  • I have ensured that relevant documentation has been added or updated.
  • I adhere to the project structure and code standards defined in the documentation.
  • My code follows the established coding style guidelines.
  • I have added tests for the new code (if applicable).
  • All existing tests have passed successfully.

Description

This PR introduces significant improvements to Pyventus' event handling system, including a new event semantic model and extended dataclass support. Key changes focus on removing the base Event class, enhancing sync event handling, and strengthening documentation. Release Notes:

Breaking Changes

  • Removed the base Event class due to improved event semantics and unnecessary redundancy.
  • Renamed the get_event_registry() method of EventLinker to get_registry().
  • Renamed the __event_registry inner property of EventLinker to __registry.
  • Renamed the get_events_by_handler() method of EventLinker to get_event_handlers_by_events().
  • Renamed the get_handlers_by_events() method of EventLinker to get_event_handlers_by_events().
  • Renamed the protected method _executor_callback() of the ExecutorEventEmitter to _callback().
  • Renamed the task name of CeleryEventEmitter from _executor to pyventus_executor to avoid collisions with other
    task names.

Added

  • Added __slots__ to EventLinkageWrapper class for more efficient memory usage.
  • Extended support for subscription and emission of any dataclass object, removing the limitation of only Event
    subclasses.
  • Added the force_async parameter to the EventHandler class and EventLinker subscription methods to be able to
    optimize the execution of sync callbacks based on their workload.
  • Introduced a new event semantic where the Python ... (Ellipsis) is now used to refer to all events on a
    subscription, like the onAny() method but with a Pythonic syntax.
  • Added the mkdocs-material social cards plugin, which provides a preview of the documentation content when shared on
    social media platforms.

Changed

  • Standardized the order of static methods, class methods, and instance methods for improved readability.
  • Applied Python best practices to optimize the methods within the EventLinker and EventEmitter classes.
  • Improved validation of variable instances in the event emitters, EventLinker, and EventHandler.
  • Updated and improved the test suite to ensure accurate validation and consistency.
  • Enabled creation date for the mkdocs git-revision-date-localized plugin.
  • Replaced the mkdocs git-authors plugin with the git-committers plugin.
  • Updated and improved the package description.
  • Updated the tutorial section to incorporate recent changes.
  • Enhanced the documentation index page and README file with new examples and better descriptions to showcase the unique
    features of Pyventus.

Removed

  • Removed the default value of the once flag in the EventHandler class.

Fixed

  • Fixed and standardized all package docstrings and code comments for consistency and clarity.
  • Addressed minor errors and details in the documentation.

commit 01e2d0f
Author: Manuel Da Pena <[email protected]>
Date:   Mon Mar 25 02:29:21 2024 -0400

    Refine Event Emitters docstring

commit fbd4b2e
Author: Manuel Da Pena <[email protected]>
Date:   Mon Mar 25 01:58:11 2024 -0400

    Update FastAPI Event Emitter docstrings

commit 23c5e16
Author: Manuel Da Pena <[email protected]>
Date:   Mon Mar 25 01:27:49 2024 -0400

    Update Celery Event Emitter docstrings

commit 4da034b
Author: Manuel Da Pena <[email protected]>
Date:   Sun Mar 24 21:53:14 2024 -0400

    Update RQ Event Emitter docstrings

commit c539635
Author: Manuel Da Pena <[email protected]>
Date:   Sun Mar 24 21:29:02 2024 -0400

    Update Executor Event Emitter docstrings

commit 1cca568
Author: Manuel Da Pena <[email protected]>
Date:   Sun Mar 24 21:10:48 2024 -0400

    Update AsyncIO Event Emitter docstrings

commit e3e12cd
Author: Manuel Da Pena <[email protected]>
Date:   Sun Mar 24 18:39:04 2024 -0400

    Update Event Emitter docs

commit d9221d2
Author: Manuel Da Pena <[email protected]>
Date:   Sun Mar 24 15:08:35 2024 -0400

    Update color of badges
…proved clarity and consistency"

This reverts commit 8aa09df.
- Improved performance of the event emitter and event linker.
- Introduced a new event semantic where ellipsis (...) refers to all events.
- Now supports subscription and emission of any dataclass object.
@mdapena mdapena added dependencies Pull requests that update a dependency feature New feature or request enhancement Suggests an improvement or enhancement to an existing feature documentation Improvements or additions to documentation labels Apr 9, 2024
@mdapena mdapena merged commit 1a7b89c into master Apr 9, 2024
11 checks passed
@mdapena mdapena deleted the event-semantic-and-improvements branch April 9, 2024 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency documentation Improvements or additions to documentation enhancement Suggests an improvement or enhancement to an existing feature feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant