Skip to content

Commit 29a4b73

Browse files
Add Rate-Limit xDS config server related control plane functionality (#598)
* Add Rate-Limit xDS config server related control plane functionality #595 Signed-off-by: Renuka Fernando <[email protected]>
1 parent 26dd058 commit 29a4b73

File tree

6 files changed

+830
-0
lines changed

6 files changed

+830
-0
lines changed

pkg/cache/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ const (
4848
Secret
4949
Runtime
5050
ExtensionConfig
51+
RateLimitConfig
5152
UnknownType // token to count the total number of supported types
5253
)

pkg/cache/v3/resource.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
runtime "github.com/envoyproxy/go-control-plane/envoy/service/runtime/v3"
3131
"github.com/envoyproxy/go-control-plane/pkg/cache/types"
3232
"github.com/envoyproxy/go-control-plane/pkg/resource/v3"
33+
ratelimit "github.com/envoyproxy/go-control-plane/ratelimit/config/ratelimit/v3"
3334
)
3435

3536
// GetResponseType returns the enumeration for a valid xDS type URL.
@@ -53,6 +54,8 @@ func GetResponseType(typeURL resource.Type) types.ResponseType {
5354
return types.Runtime
5455
case resource.ExtensionConfigType:
5556
return types.ExtensionConfig
57+
case resource.RateLimitConfigType:
58+
return types.RateLimitConfig
5659
}
5760
return types.UnknownType
5861
}
@@ -78,6 +81,8 @@ func GetResponseTypeURL(responseType types.ResponseType) (string, error) {
7881
return resource.RuntimeType, nil
7982
case types.ExtensionConfig:
8083
return resource.ExtensionConfigType, nil
84+
case types.RateLimitConfig:
85+
return resource.RateLimitConfigType, nil
8186
default:
8287
return "", fmt.Errorf("couldn't map response type %v to known resource type", responseType)
8388
}
@@ -104,6 +109,8 @@ func GetResourceName(res types.Resource) string {
104109
return v.GetName()
105110
case *core.TypedExtensionConfig:
106111
return v.GetName()
112+
case *ratelimit.RateLimitConfig:
113+
return v.GetName()
107114
case types.ResourceWithName:
108115
return v.GetName()
109116
default:

pkg/resource/v3/resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const (
2626
RuntimeType = APITypePrefix + "envoy.service.runtime.v3.Runtime"
2727
ThriftRouteType = APITypePrefix + "envoy.extensions.filters.network.thrift_proxy.v3.RouteConfiguration"
2828

29+
// Rate Limit service
30+
RateLimitConfigType = APITypePrefix + "ratelimit.config.ratelimit.v3.RateLimitConfig"
31+
2932
// AnyType is used only by ADS
3033
AnyType = ""
3134
)

pkg/server/v3/server.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
secretservice "github.com/envoyproxy/go-control-plane/envoy/service/secret/v3"
3939
"github.com/envoyproxy/go-control-plane/pkg/cache/v3"
4040
"github.com/envoyproxy/go-control-plane/pkg/resource/v3"
41+
rlsconfigservice "github.com/envoyproxy/go-control-plane/ratelimit/service/ratelimit/v3"
4142
)
4243

4344
// Server is a collection of handlers for streaming discovery requests.
@@ -52,6 +53,7 @@ type Server interface {
5253
secretservice.SecretDiscoveryServiceServer
5354
runtimeservice.RuntimeDiscoveryServiceServer
5455
extensionconfigservice.ExtensionConfigDiscoveryServiceServer
56+
rlsconfigservice.RateLimitConfigDiscoveryServiceServer
5557

5658
rest.Server
5759
sotw.Server
@@ -220,6 +222,10 @@ func (s *server) StreamExtensionConfigs(stream extensionconfigservice.ExtensionC
220222
return s.StreamHandler(stream, resource.ExtensionConfigType)
221223
}
222224

225+
func (s *server) StreamRlsConfigs(stream rlsconfigservice.RateLimitConfigDiscoveryService_StreamRlsConfigsServer) error {
226+
return s.StreamHandler(stream, resource.RateLimitConfigType)
227+
}
228+
223229
// VHDS doesn't support SOTW requests, so no handler for it exists.
224230

225231
// Fetch is the universal fetch method.
@@ -291,6 +297,14 @@ func (s *server) FetchExtensionConfigs(ctx context.Context, req *discovery.Disco
291297
return s.Fetch(ctx, req)
292298
}
293299

300+
func (s *server) FetchRlsConfigs(ctx context.Context, req *discovery.DiscoveryRequest) (*discovery.DiscoveryResponse, error) {
301+
if req == nil {
302+
return nil, status.Errorf(codes.Unavailable, "empty request")
303+
}
304+
req.TypeUrl = resource.RateLimitConfigType
305+
return s.Fetch(ctx, req)
306+
}
307+
294308
// VHDS doesn't support REST requests, so no handler exists for this.
295309

296310
func (s *server) DeltaStreamHandler(stream stream.DeltaStream, typeURL string) error {

0 commit comments

Comments
 (0)