syntax = "proto3";

package envoy.extensions.filters.network.rocketmq_proxy.v3;

import "envoy/config/core/v3/base.proto";
import "envoy/config/route/v3/route_components.proto";
import "envoy/type/matcher/v3/string.proto";

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

option java_package = "io.envoyproxy.envoy.extensions.filters.network.rocketmq_proxy.v3";
option java_outer_classname = "RouteProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/rocketmq_proxy/v3;rocketmq_proxyv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Rocketmq Proxy Route Configuration]
// Rocketmq Proxy :ref:`configuration overview <config_network_filters_rocketmq_proxy>`.

message RouteConfiguration {
  // The name of the route configuration.
  string name = 1;

  // The list of routes that will be matched, in order, against incoming requests. The first route
  // that matches will be used.
  repeated Route routes = 2;
}

message Route {
  // Route matching parameters.
  RouteMatch match = 1 [(validate.rules).message = {required: true}];

  // Route request to some upstream cluster.
  RouteAction route = 2 [(validate.rules).message = {required: true}];
}

message RouteMatch {
  // The name of the topic.
  type.matcher.v3.StringMatcher topic = 1 [(validate.rules).message = {required: true}];

  // Specifies a set of headers that the route should match on. The router will check the request’s
  // headers against all the specified headers in the route config. A match will happen if all the
  // headers in the route are present in the request with the same values (or based on presence if
  // the value field is not in the config).
  repeated config.route.v3.HeaderMatcher headers = 2;
}

message RouteAction {
  // Indicates the upstream cluster to which the request should be routed.
  string cluster = 1 [(validate.rules).string = {min_len: 1}];

  // Optional endpoint metadata match criteria used by the subset load balancer.
  config.core.v3.Metadata metadata_match = 2;
}
