common.cluster

Cluster utilities for executing operations across multiple nodes.

async execute_on_cluster(clients: List[Any], operation: Callable[[Any], Any]) ByNodeName[source]

Execute an operation on all nodes in the cluster.

Parameters:
  • clients – List of node clients

  • operation – Function to execute on each client

Returns:

Dictionary mapping node DIDs to operation results

prepare_plaintext_request(options: Dict[str, Any]) Dict[Did, Any][source]

Prepares a plaintext request by replicating the body for each node.

Parameters:

options – Dictionary containing ‘clients’ and ‘body’

Returns:

Dictionary mapping node DIDs to request payloads

async prepare_concealed_request(options: Dict[str, Any]) Dict[Did, Any][source]

Prepares a request by concealing its data for distribution to all nodes.

Parameters:

options – Dictionary containing ‘key’, ‘clients’, and ‘body’

Returns:

Dictionary mapping node DIDs to encrypted payloads

process_plaintext_response(results: ByNodeName, strategy: str = 'first') Any[source]

Selects a single canonical response from a map of node results.

Parameters:
  • results – Dictionary of results by node

  • strategy – Strategy for selecting response (“first” or “random”)

Returns:

Selected response

async process_concealed_list_response(options: Dict[str, Any]) List[Dict[str, Any]][source]

Processes and reveals a list of documents from a cluster response.

Parameters:

options – Dictionary containing ‘key’ and ‘resultsByNode’

Returns:

List of revealed documents

async process_concealed_object_response(options: Dict[str, Any]) Dict[str, Any][source]

Processes and reveals a single document from a cluster response.

Parameters:

options – Dictionary containing ‘key’ and ‘resultsByNode’

Returns:

Revealed document