// Copyright 2025 Envoy Project Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package envoy.extensions.filters.http.stateful_session.v3;

import "envoy/config/core/v3/extension.proto";

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

option java_package = "io.envoyproxy.envoy.extensions.filters.http.stateful_session.v3";
option java_outer_classname = "StatefulSessionProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/stateful_session/v3;stateful_sessionv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Stateful session filter]
// Stateful session :ref:`configuration overview <config_http_filters_stateful_session>`.
// [#extension: envoy.filters.http.stateful_session]

message StatefulSession {
  // Specifies the implementation of session state. This session state is used to store and retrieve the address of the
  // upstream host assigned to the session.
  //
  // [#extension-category: envoy.http.stateful_session]
  config.core.v3.TypedExtensionConfig session_state = 1;

  // Determines whether the HTTP request must be strictly routed to the requested destination. When set to ``true``,
  // if the requested destination is unavailable, Envoy will return a 503 status code. The default value is ``false``,
  // which allows Envoy to fall back to its load balancing mechanism. In this case, if the requested destination is not
  // found, the request will be routed according to the load balancing algorithm.
  bool strict = 2;
}

message StatefulSessionPerRoute {
  oneof override {
    option (validate.required) = true;

    // Disable the stateful session filter for this particular vhost or route. If disabled is
    // specified in multiple per-filter-configs, the most specific one will be used.
    bool disabled = 1 [(validate.rules).bool = {const: true}];

    // Per-route stateful session configuration that can be served by RDS or static route table.
    StatefulSession stateful_session = 2;
  }
}
