Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR:
The rationale for switching to JSON by default is that Gob requires users to explicitly register their data types, and DBOS is limited in how it can automatically do the registration for users. If an application reads any workflow/step input/output where the types have not been registered by the current code (e.g., previous version or recover a workflow which does ListWorkflows for other workflows that have not been seen by the runtime yet.), the read will error because we can't decode.
The only way to handle these corner case is for the user to manually register their types, which makes for a poor UX and bad surprises.
PR details
JSON serializer
JSON does lose schema information when encoding a data structure. This means that when decoding, JSON can only return a generic
map[string]interface. We address this by automating a round of marshal/unmarshal in places where we know the data type. However, this is not possible on theListWorkflowsandGetWorkflowStepspath, which are not generic. On this path, the user must reconvert the input/output to their known type if they wish to use it typed (which they can do with a marshaling round, or usinggithub.com/mitchellh/mapstructure.More automated registration for Gob serializer
serialize, which fixes the cases where a workflow signature has an interface input and/or output. At registration time, we do not know the underlying concrete value of the interface and cannot register it properlyTests
We test both serializer on all path where they're used:
With the JSON serializer, it is know possible to have workflow signatures with
any. We test this case, in which the nil values should be stored as empty strings in the database.