for_each_primary_endpoint

Function for_each_primary_endpoint 

Source
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)>
where F: Fn(String, String, Option<RndcKeyData>) -> Fut, Fut: Future<Output = Result<()>>,
Expand description

Execute an operation on all endpoints of all primary instances in a cluster.

This helper function handles the common pattern of:

  1. Finding all primary pods for a cluster
  2. Collecting unique instance names
  3. Optionally loading RNDC key from each instance
  4. Getting endpoints for each instance
  5. Executing a provided operation on each endpoint

§Arguments

  • client - Kubernetes API client
  • namespace - Namespace of the cluster
  • cluster_ref - Name of the Bind9Cluster or ClusterBind9Provider
  • is_cluster_provider - Whether this is a cluster provider (cluster-scoped)
  • with_rndc_key - Whether to load RNDC key from each instance
  • port_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<()>

§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