Structure workflows for identical workflows with cooldowns

Hi, I’m trying to assess using temporal for my use case and I was wondering whether there’s a way to structure my workflows/activities for this scenario?

* e.g. Workflow 1 is to deploy a new config to all the nodes.
	* calls an activity GetAllNodes()
	* creates a child workflow DeployConfig(node) for each node
* Workflow2 is to provision a new node
	* calls workflow CreateNode
	* calls workflow DeployConfig(node) on the new node
  • Assume Workflow2 runs at 12:30 and finishes at 12:40. Workflow 1 then runs at 13:00.

Is there a way to avoid running DeployConfig(node) from workflow1 in the same hour as workflow2 runs DeployConfig(node)?

If the requirement is to not have 2 executions of DeployConfig running at the same time, then it can be achieved by passing in a deterministic WorkflowId each time DeployConfig workflow is started. For instance you can use the nodeId with a WorkflowType suffix. For example if the unique Id for a node is nodeA then you can pass in nodeA-DeployConfig as the workflowId when starting DeployConfig child workflow from workflow 1 & 2. This will result in one child workflow execution going through and the other would fail with workflow execution already running error.

But looks like you want to allow only one config deployment during one hour. In this case, I would recommend to have a workflow execution always running for each entity (node in this case). So instead of instantiating DeployConfig as a child workflow you send a DeployConfig signal to NodeManagement workflow. Since an instance of this workflow is always running you can keep any state like lastDeployConfigTimestamp and uses this state to decide whether to deploy config to the node or dedupe request if a config is already deployed within last hour.
The only drawback of this approach is signal is one directional. So if you need to send a response back to the caller than you have achieve that by sending another signal from NodeManagement workflow to the caller.