View Source ProcessHub.Request.Handler.StartChildrenRequest (ProcessHub v0.5.0-beta)
Node-level request for starting child processes.
This module represents a request to start children on a specific target node.
It implements the CrossNodeRequest protocol for execution on target nodes.
Structure
The request contains:
- Routing fields (transaction_id, hub_id, originating_node, reply_to)
- Target node and children data
- Operation-specific fields (request_signature)
- Response tracking (start_results)
Usage
Requests are typically created via new/3 from an Operation,
then dispatched to target nodes where execute/2 runs the actual start logic.
Summary
Functions
Aggregates results from all sub-requests into a final StartResult.
Builds the response data to send back to the coordinator from PostStartData results.
Execute the request on the target node.
Factory: Creates a contraction request for ColdSwap topology contraction.
Factory: Creates a migration request for topology expansion.
Creates a new StartChildrenRequest for a specific target node.
Post-processes the aggregated result.
Returns the response message type for routing.
Converts post-start results to storage format for registry insertion.
Converts StartChildrenRequest to keyword options for backward compatibility.
Types
@type t() :: %ProcessHub.Request.Handler.StartChildrenRequest{ children: [ %{ child_spec: ProcessHub.child_spec(), metadata: ProcessHub.child_metadata() } ], hub_id: ProcessHub.hub_id() | nil, node: node(), options: keyword(), originating_node: node() | nil, post_action: ProcessHub.Request.PostAction.t() | nil, reply_to: [pid()] | nil, request_signature: non_neg_integer() | nil, results: [{ProcessHub.child_id(), term()}] | nil, status: :pending | :dispatched | :completed, transaction_id: reference() | nil }
Functions
@spec aggregate_results(ProcessHub.Service.RequestManager.t()) :: ProcessHub.StartResult.t()
Aggregates results from all sub-requests into a final StartResult.
Called when all nodes have responded (or the operation has timed out). Collects results from all sub-requests and produces a single result struct.
Parameters
operation- The completed Operation struct with all sub-request results
Returns
A ProcessHub.StartResult struct with aggregated results.
@spec build_node_response([ ProcessHub.Request.Handler.StartChildrenRequest.PostStartData.t() ]) :: [ {ProcessHub.child_id(), term()} ]
Builds the response data to send back to the coordinator from PostStartData results.
@spec execute(t(), ProcessHub.Hub.t()) :: :ok | {:error, :partitioned}
Execute the request on the target node.
This function is invoked on the target node when the request arrives. It performs the actual work (starting children) and sends a response back to the coordinator.
Parameters
request- The StartChildrenRequest structhub- The Hub struct on the target node
Returns
:okon success{:error, :partitioned}if the node is partitioned
@spec for_contraction(ProcessHub.Hub.t(), [{ProcessHub.child_spec(), map()}]) :: t()
Factory: Creates a contraction request for ColdSwap topology contraction.
@spec for_migration( ProcessHub.Hub.t(), node(), [{ProcessHub.child_spec(), map()}], keyword() ) :: t()
Factory: Creates a migration request for topology expansion.
Options
:post_action- OptionalPostActionto execute after children are started
@spec new(ProcessHub.Service.RequestManager.t(), node(), [map()]) :: t()
Creates a new StartChildrenRequest for a specific target node.
Called by RequestManager.compose_sub_requests/1 for each node in the operation's
nodes_data. The returned struct contains all information needed to
execute the request on the target node.
Parameters
operation- The Operation struct containing common operation datatarget_node- The node this request will be sent tochildren- List of child data maps for this node
Returns
A new StartChildrenRequest struct.
@spec post_process( ProcessHub.Service.RequestManager.t(), ProcessHub.StartResult.t(), ProcessHub.Hub.t() ) :: ProcessHub.StartResult.t()
Post-processes the aggregated result.
Handles rollback logic when on_failure: :rollback is set and the operation
had errors. For successful operations or when on_failure: :continue, returns
the result unchanged.
Parameters
operation- The completed Operation structresult- The aggregated StartResulthub- The Hub struct for context
Returns
The StartResult, potentially modified with rollback flag if rollback was performed.
@spec response_type() :: atom()
Returns the response message type for routing.
This atom is used by the coordinator to route responses to the correct
handler. Matches the message type sent by RequestManager.send_response/3.
Returns
The atom :operation_response.
@spec store_format([ ProcessHub.Request.Handler.StartChildrenRequest.PostStartData.t() ]) :: map()
Converts post-start results to storage format for registry insertion.
Converts StartChildrenRequest to keyword options for backward compatibility.