faust icon indicating copy to clipboard operation
faust copied to clipboard

#556 Add value_serializer parameter to table and collection definit…

Open degerahmet opened this issue 9 months ago • 0 comments

Issue #556

This pull request includes several changes to the faust library, specifically in the faust/app/base.py and faust/tables/base.py files. The most important changes involve the addition of a value_serializer parameter to various methods and the correction of a minor typo.

Additions of value_serializer parameter:

  • faust/app/base.py: Added value_serializer parameter to the Table method and included it in the method's body. [1] [2]
  • faust/tables/base.py: Added value_serializer parameter to the __init__ method of the Table class and used it in place of the previous value serializer assignment. [1] [2]
  • faust/tables/base.py: Included value_serializer in the _new_store_by_url method.

Minor typo correction:

  • faust/app/base.py: Corrected a typo in the comment for _app_tasks initialization.

EDIT

Title

Fix value_serializer Issue in send_soon Method and Add Error Handling for None Event in _send_changelog

Description

This PR resolves an issue where the value_serializer was not properly set in the send_soon method, leading to an AssertionError during testing. Additionally, it enhances error handling in the _send_changelog method by explicitly raising a RuntimeError if the event parameter is None.

These changes ensure more robust behavior and prevent silent failures when processing changelog events.

Changes Made

File: faust/tables/base.py

  • Fixed: Ensured value_serializer is correctly set in the send_soon method.
  • Enhanced: Added a safeguard in _send_changelog to check for None events and raise a RuntimeError if encountered.
  • Updated: Set default values for key_serializer and value_serializer to 'json' in _send_changelog to prevent serialization issues.

File: tests/unit/tables/test_base.py

  • Updated: The test_send_changelog method now verifies that value_serializer is correctly set.
  • Added: A new test case to ensure a RuntimeError is raised when event is None in _send_changelog.

Testing

  • Ran all unit tests in tests/unit/tables/test_base.py to confirm no regressions.
  • Verified that value_serializer defaults to 'json' and is correctly assigned in send_soon.
  • Confirmed that _send_changelog raises a RuntimeError when event is None.

Related Issues

Fixes #556

Checklist

✅ Code changes are complete.
✅ Unit tests have been updated to cover the changes.
✅ All tests pass locally.
✅ Documentation has been updated (if applicable).

degerahmet avatar Mar 18 '25 17:03 degerahmet