Skip to content

Adds Encode and Decode logic for "arbitrary" objects for Durable Python #57

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

Merged
merged 6 commits into from
Apr 24, 2020

Conversation

davidmrdavid
Copy link
Contributor

This PR is a kind of "follow-up" to: #53

The Durable Functions Python group is looking to support custom objects as inputs and outputs for their Orchestrations and Activity Functions. To do this, we establish a kind of "contract" with the user that their custom classes will provide static to_json and from_json methods that we can use to serialize and deserialize their object instances. These functions get called as json.dumps and json.loads 'callbacks` at various points and throughout the library and the durable-python code itself.

So this PR does three things:

  1. It defines the helper methods to serialize and de-serialize custom objects
  2. Uses them in the ActivityTriggerConverters's decode and encode methods
  3. Exposes them for further usage in Durable Python

I worry that the last point may be controversial, because we are exposing a framework-internal function and users doing import azure.functions would be able to see them. Now, the fact that they are prefixed by two underscores should signal that they are not for public usage. Another idea I had was to bundle the two serialization functions under a __serialization__ module, and export that instead. Please let me know what you think, and than you 😸

@Hazhzeng
Copy link
Contributor

Since these custom_objects are very durable function specific, I would suggest just let our user to do import azure.functions.durable_functions.__serialize_custom_object instead

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.

2 participants