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

Assign blessed_key to metadata if blessed_key is defined #422

Merged
merged 3 commits into from
Dec 15, 2022

Conversation

wbarnha
Copy link
Member

@wbarnha wbarnha commented Dec 14, 2022

Fixes #421.

@@ -592,7 +592,7 @@ def to_representation(self) -> Mapping[str, Any]:
payload = self.asdict()
options = self._options
if options.include_metadata:
payload["__faust"] = {"ns": options.namespace}
payload[self._blessed_key] = {"ns": options.namespace}
Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently options.allow_blessed_key is defined in faust/types/models.py, do we want to add this as well to check before adding the blessed key?

Copy link
Member Author

Choose a reason for hiding this comment

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

faust/faust/models/base.py

Lines 153 to 160 in ebc7777

#: Serialized data may contain a "blessed key" that mandates
#: how the data should be deserialized. This probably only
#: applies to records, but we need to support it at Model level.
#: The blessed key has a dictionary value with a ``ns`` key:
#: data = {.., '__faust': {'ns': 'examples.simple.Withdrawal'}}
#: When ``Model._maybe_reconstruct` sees this key it will look
#: up that namespace in the :data:`registry`, and if it exists
#: select it as the target model to use for serialization.

Guess we don't need the option here.

@wbarnha wbarnha merged commit e541793 into faust-streaming:master Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Faust doesn't serialize properly the model with a blessed_key
1 participant