Skip to content

Uniformize patched() API in all SDKs #591

@mjameswh

Description

@mjameswh

Describe the solution you'd like

In short

  • Support the patched(patchId, memoized): boolean and deprecatePatch(patchId, memoized): boolean APIs in all SDKs

  • Keep backward compatibility on existing APIs in each SDK, but deprecate those APIs

    • The objective is to encourage users to move to the uniformized, simpler and less confusing APIs.
    • Documentation on deprecated APIs should clearly indicate how existing calls may safely get converted.
  • In Core-based SDKs, delegate handling of the patched logic to Core

Some details

  • The memoized flag needs to be stored in the Marker command, as part of the Workflow history.

  • Inconsistent usage of the memoized flag should result in a Non-Determinism Error.

  • Core SDK will implement this first, using the TS SDK as reference for the non-memoized bahavior, and Python/.Net for the memoized behavior. Java and Go will then mirror Core's implementation.

Existing APIs

All SDKs already provide some form of Workflow command to record versioning markers into Workflow history, but those APIs are inconsistent across the board:

  • Go, Java and PHP have GetVersion, which associates a textual identifier and a numeric value, leaving to the user the responsibility of using these appropriately. GetVersion checks are memoized, meaning that calling GetVersion with a same textual identifier multiple time in the lifetime of a single Workflow Execution will always return the same numeric value as was first returned.

  • Python, .NET and Ruby have the patched() and deprecate_patch() functions, which only takes a textual identifier, and return boolean value indicating either the new code should be executed or not. The return value is memoized.

  • TypeScript also have patched() and deprecatePatch() functions, but those are non-memoized.

Per-SDK Tickets

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions