Enhancements to Decorators and Workflow Metadata Management
Release Notes
Enhancements to Decorators and Workflow Metadata Management
In this release, we've made significant improvements to the way decorators handle metadata registration for workflows. These changes ensure robust, isolated metadata management, avoiding cross-contamination and correctly registering workflow queries, signals, and properties. The updates will enhance the developer experience and provide more predictable behavior in Temporal workflows.
Key Changes:
-
Improved
Property
Decorator for Workflow Properties:- The
Property
decorator now directly uses thepropertyKey
(name of the property) to define bothqueryName
andsignalName
. This ensures that queries and signals are uniquely and clearly associated with the properties they manage. - The decorator utilizes
Reflect
metadata to safely register and retrieve metadata on the class or instance, ensuring no interference between classes or prototypes.
- The
-
Refined Getter and Setter Registration with
Get
andSet
Decorators:Get
andSet
decorators now properly define and manage metadata for getters and setters, usingReflect
to avoid potential prototype pollution.- Each decorated property is registered with a unique getter and setter, preventing any unwanted sharing of state or behavior across different workflow classes.
-
Consistent Metadata Keys and Usage:
- Introduced constants for metadata keys (
PROPERTY_METADATA_KEY
,GETTER_METADATA_KEY
,SETTER_METADATA_KEY
) to maintain consistency across the codebase. - The metadata keys are used with
Reflect
API to ensure that metadata is correctly isolated and retrieved for each specific class or instance.
- Introduced constants for metadata keys (
-
Robust Binding of Queries, Signals, and Properties in Workflows:
- Improved binding functions (
bindProperties
,bindQueries
,bindSignals
) to correctly collect and bind metadata using theReflect
API. This guarantees that all queries, signals, and properties are properly registered during the workflow initialization phase. - Enhanced error handling and logging to provide more informative error messages if queries or signals are not registered correctly.
- Improved binding functions (
-
Enhanced Workflow Execution Reliability:
- The improvements ensure that workflows correctly register handlers for all expected signals and queries, avoiding issues such as
QueryNotRegisteredError
. - Added robust metadata collection and binding logic to support complex workflows with dynamic state management and signal/query handling.
- The improvements ensure that workflows correctly register handlers for all expected signals and queries, avoiding issues such as
Benefits:
- Increased Stability and Predictability: The changes ensure that workflows operate as expected without unintended side effects due to improperly registered signals or queries.
- Better Developer Experience: Clearer, more predictable behavior when using decorators, making it easier for developers to define and manage Temporal workflows.
- Improved Metadata Management: Using
Reflect
for metadata ensures a clean, isolated metadata state, avoiding conflicts between classes or instances.