View Source ProcessHub.Request.Handler.StopChildrenRequest (ProcessHub v0.5.0-beta)
Node-level request for stopping child processes.
This module represents a request to stop 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
- Response tracking (stop_results)
Usage
Requests are typically created via new/3 from an Operation,
then dispatched to target nodes where execute/2 runs the actual stop logic.
Summary
Functions
Aggregates results from all sub-requests into a final StopResult.
Builds the response data to send back to the coordinator from post_stop_results.
Execute the request on the target node.
Creates a new StopChildrenRequest for a specific target node.
Post-processes the aggregated result.
Returns the response message type for routing.
Converts StopChildrenRequest to keyword options for backward compatibility.
Types
@type t() :: %ProcessHub.Request.Handler.StopChildrenRequest{ children: [map()], hub_id: ProcessHub.hub_id() | nil, node: node(), options: keyword(), originating_node: node() | nil, reply_to: [pid()] | nil, results: [{ProcessHub.child_id(), term()}] | nil, status: :pending | :dispatched | :completed, transaction_id: reference() | nil }
Functions
@spec aggregate_results(ProcessHub.Service.RequestManager.t()) :: ProcessHub.StopResult.t()
Aggregates results from all sub-requests into a final StopResult.
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.StopResult struct with aggregated results.
@spec build_node_response([map()]) :: [{ProcessHub.child_id(), term()}]
Builds the response data to send back to the coordinator from post_stop_results.
Accepts a list of maps with :child_id key (from children).
@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 (stopping children) and sends a response back to the coordinator.
Parameters
request- The StopChildrenRequest structhub- The Hub struct on the target node
Returns
:okon success{:error, :partitioned}if the node is partitioned
@spec new(ProcessHub.Service.RequestManager.t(), node(), [map()]) :: t()
Creates a new StopChildrenRequest 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 StopChildrenRequest struct.
@spec post_process( ProcessHub.Service.RequestManager.t(), ProcessHub.StopResult.t(), ProcessHub.Hub.t() ) :: ProcessHub.StopResult.t()
Post-processes the aggregated result.
For stop operations, no post-processing is needed - the result is returned unchanged.
Parameters
_operation- The completed Operation struct (unused)result- The aggregated StopResult_hub- The Hub struct for context (unused)
Returns
The StopResult unchanged.
@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.
Converts StopChildrenRequest to keyword options for backward compatibility.