# Illustrative extension to 02, based on the prepared istio-concurrency POC.
# Custom Envoy objects depend on generated route/vhost names and exact proxy version.
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: example-obrh-url-capacity
  namespace: obrh-example
spec:
  priority: -10 # Ordering is NOT inheritance of sibling route policies.
  workloadSelector:
    labels:
      app: obrh-direct-example
  configPatches:
  - applyTo: CLUSTER
    match:
      context: SIDECAR_INBOUND
    patch:
      operation: ADD
      value:
        name: example-debit-credit-v2
        type: STATIC
        connect_timeout: 1s
        load_assignment:
          cluster_name: example-debit-credit-v2
          endpoints:
          - lb_endpoints:
            - endpoint:
                address:
                  socket_address:
                    address: 127.0.0.1
                    port_value: 8080
        circuit_breakers:
          thresholds:
          - priority: DEFAULT
            max_connections: 50
            max_pending_requests: 5 # Explicit finite wait capacity; not a deadline.
            max_requests: 50 # Independent of the ordinary cluster's 200.
            max_retries: 0
  - applyTo: HTTP_ROUTE
    match:
      context: SIDECAR_INBOUND
      routeConfiguration:
        vhost:
          name: inbound|http|8080 # Verify this name in the selected proxy's xDS.
    patch:
      operation: INSERT_FIRST
      value:
        name: example-debit-credit-v2
        match:
          prefix: /
          headers:
          - name: REQUEST-URL # Trusted gateway must overwrite/normalize this header.
            string_match:
              exact: /clearing-settlement/casa-payment-upi/debitCreditTxn/v2
        route:
          cluster: example-debit-credit-v2
          timeout: 5s # Illustrative bounded route deadline; tune to business budget.
          retry_policy:
            num_retries: 0 # Payment retries require a separate idempotency contract.
          # Keep actions only where the matching existing bucket/filter is enabled.
          # Actions generate descriptors; they do not define token buckets.
          rate_limits:
          - actions:
            - request_headers:
                header_name: REQUEST-URL
                descriptor_key: path
          - actions:
            - request_headers:
                header_name: PRODUCT-PROCESSOR
                descriptor_key: pp
# IL uses its own trusted OBP-URL identity and selector; do not reuse this Direct match.
# One selected route uses one cluster; the ordinary 200 counter is not also debited.
