Skip to main content

WG Create

Creates a Wait Group identifier to be used in synchronizing parallel execution.

How It Works

  1. A new WaitGroup object is created with an internal sync.WaitGroup and delta counter initialized to 0
  2. A unique Wait Group ID is generated using a random ID generator
  3. The WaitGroup object is stored in a global thread-safe map with the generated ID as the key
  4. The Wait Group ID is assigned to the configured output variable
  5. The message passes through with the Wait Group ID
  6. When the flow closes, all wait groups are automatically cleaned up and deleted

Requirements

  • No prerequisites - this node can be called anywhere in the flow
  • The Wait Group ID must be passed to WG Add, WG Done, and WG Wait nodes for coordination

Error Handling

Error CodeDescriptionCause
Core.WaitGroup.Create.ErrOnCreateConfig parse errorInvalid node configuration during creation
Core.WaitGroup.Create.ErrOnMessageMessage parse errorInvalid message format received
Core.WaitGroup.Create.OutputMarshalOutput marshaling errorFailed to convert message to JSON

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If ContinueOnError property is true, no error is caught when the project is executed even if the Catch node is used.

Output

  • Wait Group ID - Identifier of the created wait group. Store this in a variable to use with WG Add, WG Done, and WG Wait.

Usage Examples

Example 1: Parallel Data Processing

WG Create → msg.wgID
└─ WG Add (wgID, Delta: 3)
└─ Split into 3 parallel branches:
├─ Branch 1: Process Task 1 → WG Done (wgID)
├─ Branch 2: Process Task 2 → WG Done (wgID)
└─ Branch 3: Process Task 3 → WG Done (wgID)
└─ WG Wait (wgID)
└─ All Tasks Complete - Continue Flow

Create a wait group to synchronize 3 parallel processing branches.

Example 2: Dynamic Parallel Execution

WG Create → msg.wgID
└─ Get Task List → msg.tasks (array of tasks)
└─ WG Add (wgID, Delta: msg.tasks.length)
└─ For Each (msg.tasks)
├─ Trigger Parallel Flow (task)
│ └─ (In parallel flow) Process Task → WG Done (wgID)
└─ [Return to For Each]
└─ WG Wait (wgID)
└─ All Parallel Tasks Complete

Create a wait group for a dynamic number of parallel operations.

Example 3: Multi-Stage Parallel Pipeline

WG Create → msg.stage1WG
└─ WG Add (stage1WG, Delta: 5)
└─ Launch 5 parallel data fetchers
└─ Each fetcher: Fetch Data → WG Done (stage1WG)
└─ WG Wait (stage1WG)
└─ Stage 1 Complete
└─ WG Create → msg.stage2WG
└─ WG Add (stage2WG, Delta: 3)
└─ Launch 3 parallel processors
└─ WG Wait (stage2WG)
└─ All Stages Complete

Use multiple wait groups for multi-stage parallel processing pipelines.

Usage Notes

  • Each WG Create generates a unique Wait Group ID - don't reuse IDs across different parallel operations
  • Wait groups are automatically cleaned up when the flow completes or errors
  • The delta counter starts at 0 - use WG Add to set how many parallel operations to wait for
  • Store the Wait Group ID in a variable (msg, flow, or global scope) to share across branches
  • Wait groups are thread-safe and can be used with truly parallel execution

Tips

  • Create one wait group per parallel operation set - don't reuse wait groups
  • Store the Wait Group ID in a message variable if using within a single flow
  • Store in a flow or global variable if coordinating across multiple sub-flows
  • Always call WG Add before starting parallel branches to avoid race conditions
  • Use meaningful variable names for Wait Group IDs (e.g., msg.dataFetchWG, msg.processingWG)
  • Wait groups are perfect for fan-out/fan-in patterns in parallel processing
  • Clean up is automatic - no need to manually delete wait groups
  • WG Add - Set the number of parallel operations to wait for
  • WG Done - Signal that a parallel operation has completed
  • WG Wait - Block until all parallel operations complete