[thrift_proxy] Add and implement weighted clusters to thrift.RouteAction (#4315)

Adding the ability to add weighted clusters to the thrift router's RouteAction proto. This works much like the http one and borrows a great deal of code from it. Since the thrift_proxy Route and RouteEntry interfaces are much more bare bones, was able to implement the WeightedClusterEntry class.

Risk Level: Low
Testing: Tests, new and old, pass
Doc Changes: inline
Release Notes: n/a

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>

Mirrored from https://github.com/envoyproxy/envoy @ a50ac3747623a7fa74a5dbd33eacf0808dbf4d0c
pull/620/head
data-plane-api(CircleCI) 6 years ago
parent d962d78e04
commit ece7d99193
  1. 1
      envoy/config/filter/network/thrift_proxy/v2alpha1/BUILD
  2. 38
      envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto

@ -9,6 +9,7 @@ api_proto_library_internal(
"thrift_proxy.proto",
],
deps = [
"//envoy/api/v2/core:base",
"//envoy/api/v2/route",
],
)

@ -3,7 +3,11 @@ syntax = "proto3";
package envoy.config.filter.network.thrift_proxy.v2alpha1;
option go_package = "v2";
import "envoy/api/v2/core/base.proto";
import "envoy/api/v2/route/route.proto";
import "google/protobuf/wrappers.proto";
import "validate/validate.proto";
import "gogoproto/gogo.proto";
@ -66,8 +70,36 @@ message RouteMatch {
repeated envoy.api.v2.route.HeaderMatcher headers = 4;
}
// [#comment:next free field: 2]
// [#comment:next free field: 3]
message RouteAction {
// Indicates the upstream cluster to which the request should be routed.
string cluster = 1 [(validate.rules).string.min_bytes = 1];
oneof cluster_specifier {
option (validate.required) = true;
// Indicates a single upstream cluster to which the request should be routed
// to.
string cluster = 1 [(validate.rules).string.min_bytes = 1];
// Multiple upstream clusters can be specified for a given route. The
// request is routed to one of the upstream clusters based on weights
// assigned to each cluster.
WeightedCluster weighted_clusters = 2;
}
}
// Allows for specification of multiple upstream clusters along with weights that indicate the
// percentage of traffic to be forwarded to each cluster. The router selects an upstream cluster
// based on these weights.
message WeightedCluster {
message ClusterWeight {
// Name of the upstream cluster.
string name = 1 [(validate.rules).string.min_bytes = 1];
// When a request matches the route, the choice of an upstream cluster is determined by its
// weight. The sum of weights across all entries in the clusters array determines the total
// weight.
google.protobuf.UInt32Value weight = 2 [(validate.rules).uint32.gte = 1];
}
// Specifies one or more upstream clusters associated with the route.
repeated ClusterWeight clusters = 1 [(validate.rules).repeated .min_items = 1];
}

Loading…
Cancel
Save