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

Link to this function

aggregate_results(operation)

View Source

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.

Link to this function

build_node_response(post_stop_results)

View Source
@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 struct
  • hub - The Hub struct on the target node

Returns

  • :ok on success
  • {:error, :partitioned} if the node is partitioned
Link to this function

new(operation, target_node, children)

View Source
@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 data
  • target_node - The node this request will be sent to
  • children - List of child data maps for this node

Returns

A new StopChildrenRequest struct.

Link to this function

post_process(operation, result, hub)

View Source

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.

@spec to_stop_opts(t()) :: keyword()

Converts StopChildrenRequest to keyword options for backward compatibility.