Closed sfmskywalker closed 2 months ago
To implement a new API endpoint to refresh workflow definitions in real-time, you would need to follow these steps:
Define the Endpoint Route and Method:
Create a new controller or extend an existing one with a method to handle the POST request to /actions/workflow-definitions/refresh
.
Request Body Parsing:
Parse the incoming request body to extract the WorkflowDefinitionIds
array. If the array is empty or undefined, the operation should refresh all workflow definitions.
Permission Check:
Ensure that the caller has the required permission (actions:workflow-definitions:refresh
) to perform this action.
Service Injection:
Inject the IWorkflowDefinitionStore
service to access workflow definitions and the ITriggerIndexer
service to re-index triggers.
Fetching Workflow Definitions:
Use the IWorkflowDefinitionStore
service to fetch the workflow definitions that need to be refreshed. If WorkflowDefinitionIds
is provided, fetch those specific definitions; otherwise, fetch all published workflow definitions.
Batch Processing: To avoid memory overload, process the workflow definitions in batches. For each batch, perform the following steps:
Re-indexing Triggers:
Use the ITriggerIndexer
service to re-index the triggers for each workflow definition in the batch.
Evict Cache (if applicable): If the system uses a cache for workflow definitions, ensure that the cache is evicted for the updated definitions.
Response: Once all the workflow definitions have been processed, return a success response to the caller.
Evict Workflow Definition Service Cache:
Update the EvictWorkflowDefinitionServiceCache
handler to listen for the WorkflowTriggersIndexed
notification and evict the workflow definition service cache accordingly.
Testing: Write unit tests and integration tests to verify that the endpoint behaves as expected, including permission checks, request body parsing, batch processing, and cache eviction.
Documentation: Update the API documentation to include the new endpoint, its usage, request/response formats, and any relevant examples.
Please note that the actual implementation would require writing code in the programming language and framework used by the system, which typically involves creating controllers, services, and other components as needed.
This comment was generated by Glime.
Summary
Implement a new API endpoint to refresh workflow definitions in real-time, either for all definitions or a specified list of IDs.
Endpoint Details
Permissions Required
actions:workflow-definitions:refresh
Internal Operations
IWorkflowDefinitionStore
service.ITriggerIndexer
service for each matching workflow definition.Additional Update
EvictWorkflowDefinitionServiceCache
handler to manage theWorkflowTriggersIndexed
notification and evict the workflow definition service cache. This functionality already exists for the HTTP Workflow Trigger cache.Objective
Enhance the system's ability to dynamically refresh workflow definitions to ensure they are up-to-date without requiring a full system restart or manual intervention.