#556 Add value_serializer parameter to table and collection definit…
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: Addedvalue_serializerparameter to theTablemethod and included it in the method's body. [1] [2]faust/tables/base.py: Addedvalue_serializerparameter to the__init__method of theTableclass and used it in place of the previous value serializer assignment. [1] [2]faust/tables/base.py: Includedvalue_serializerin the_new_store_by_urlmethod.
Minor typo correction:
faust/app/base.py: Corrected a typo in the comment for_app_tasksinitialization.
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_serializeris correctly set in thesend_soonmethod. - Enhanced: Added a safeguard in
_send_changelogto check forNoneevents and raise aRuntimeErrorif encountered. - Updated: Set default values for
key_serializerandvalue_serializerto'json'in_send_changelogto prevent serialization issues.
File: tests/unit/tables/test_base.py
- Updated: The
test_send_changelogmethod now verifies thatvalue_serializeris correctly set. - Added: A new test case to ensure a
RuntimeErroris raised wheneventisNonein_send_changelog.
Testing
- Ran all unit tests in
tests/unit/tables/test_base.pyto confirm no regressions. - Verified that
value_serializerdefaults to'json'and is correctly assigned insend_soon. - Confirmed that
_send_changelograises aRuntimeErrorwheneventisNone.
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).