pub async fn for_each_primary_endpoint<F, Fut>(
client: &Client,
namespace: &str,
cluster_ref: &str,
is_cluster_provider: bool,
with_rndc_key: bool,
port_name: &str,
operation: F,
) -> Result<(Option<String>, usize)>Expand description
Execute an operation on all endpoints of all primary instances in a cluster.
This helper function handles the common pattern of:
- Finding all primary pods for a cluster
- Collecting unique instance names
- Optionally loading RNDC key from each instance
- Getting endpoints for each instance
- Executing a provided operation on each endpoint
§Arguments
client- Kubernetes API clientnamespace- Namespace of the clustercluster_ref- Name of theBind9ClusterorClusterBind9Provideris_cluster_provider- Whether this is a cluster provider (cluster-scoped)with_rndc_key- Whether to load RNDC key from each instanceport_name- Port name to use for endpoints (e.g., “rndc-api”, “dns-tcp”)operation- Async closure to execute for each endpoint- Arguments:
(pod_endpoint: String, instance_name: String, rndc_key: Option<RndcKeyData>) - Returns:
Result<()>
- Arguments:
§Returns
Returns Ok((first_endpoint, total_count)) where:
first_endpoint- Optional first endpoint encountered (useful for NOTIFY operations)total_count- Total number of endpoints processed successfully
§Errors
Returns error if:
- No primary pods found for the cluster
- Failed to load RNDC key (if requested)
- Failed to get endpoints for any instance
- The operation closure returns an error for any endpoint