syntax = "proto3";

package envoy.extensions.clusters.composite.v3;

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.clusters.composite.v3";
option java_outer_classname = "ClusterProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/clusters/composite/v3;compositev3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Composite cluster configuration]

// Configuration for the composite cluster. See the :ref:`architecture overview
// <arch_overview_composite_cluster>` for more information. This cluster type enables retry-aware
// cluster selection, allowing different retry attempts to automatically target
// different upstream clusters. Unlike the standard aggregate cluster which uses
// health-based selection, the composite cluster uses the retry attempt count to
// deterministically select which sub-cluster to route to.
//
// When retry attempts exceed the number of configured clusters, requests will fail with no
// host available.
//
// Example configuration:
//
// .. code-block:: yaml
//
//     name: composite_cluster
//     connect_timeout: 0.25s
//     lb_policy: CLUSTER_PROVIDED
//     cluster_type:
//       name: envoy.clusters.composite
//       typed_config:
//         "@type": type.googleapis.com/envoy.extensions.clusters.composite.v3.ClusterConfig
//         clusters:
//         - name: primary_cluster
//         - name: secondary_cluster
//         - name: fallback_cluster
//
// [#extension: envoy.clusters.composite]
message ClusterConfig {
  // Configuration for an individual cluster entry.
  message ClusterEntry {
    // Name of the cluster. This cluster must be defined elsewhere in the configuration.
    string name = 1 [(validate.rules).string = {min_len: 1}];
  }

  // List of clusters to use for request routing. The first cluster is used for the
  // initial request (attempt 1), the second cluster for the first retry (attempt 2),
  // and so on. Must contain at least one cluster. When retry attempts exceed the number
  // of configured clusters, requests will fail with no host available.
  repeated ClusterEntry clusters = 1 [(validate.rules).repeated = {min_items: 1}];
}
