API - Add | Remove Routing Rules (#3189)

* add RuleTag to routing rules

* add router pb commands

* add and remove routing rules api

* cleanup

* fix

* improve error msg

* add append flag
apply balancer config
This commit is contained in:
Hossin Asaadi 2024-03-29 19:17:36 +04:00 committed by GitHub
parent 8a439bf3f2
commit 53e5814d19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 901 additions and 269 deletions

View file

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v4.23.1
// - protoc-gen-go-grpc v1.2.0
// - protoc v4.25.3
// source: app/router/command/command.proto
package command
@ -18,13 +18,6 @@ import (
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
RoutingService_SubscribeRoutingStats_FullMethodName = "/xray.app.router.command.RoutingService/SubscribeRoutingStats"
RoutingService_TestRoute_FullMethodName = "/xray.app.router.command.RoutingService/TestRoute"
RoutingService_GetBalancerInfo_FullMethodName = "/xray.app.router.command.RoutingService/GetBalancerInfo"
RoutingService_OverrideBalancerTarget_FullMethodName = "/xray.app.router.command.RoutingService/OverrideBalancerTarget"
)
// RoutingServiceClient is the client API for RoutingService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
@ -33,6 +26,8 @@ type RoutingServiceClient interface {
TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error)
GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error)
OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error)
AddRule(ctx context.Context, in *AddRuleRequest, opts ...grpc.CallOption) (*AddRuleResponse, error)
RemoveRule(ctx context.Context, in *RemoveRuleRequest, opts ...grpc.CallOption) (*RemoveRuleResponse, error)
}
type routingServiceClient struct {
@ -44,7 +39,7 @@ func NewRoutingServiceClient(cc grpc.ClientConnInterface) RoutingServiceClient {
}
func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) {
stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_SubscribeRoutingStats_FullMethodName, opts...)
stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], "/xray.app.router.command.RoutingService/SubscribeRoutingStats", opts...)
if err != nil {
return nil, err
}
@ -77,7 +72,7 @@ func (x *routingServiceSubscribeRoutingStatsClient) Recv() (*RoutingContext, err
func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) {
out := new(RoutingContext)
err := c.cc.Invoke(ctx, RoutingService_TestRoute_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/TestRoute", in, out, opts...)
if err != nil {
return nil, err
}
@ -86,7 +81,7 @@ func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteReque
func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) {
out := new(GetBalancerInfoResponse)
err := c.cc.Invoke(ctx, RoutingService_GetBalancerInfo_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/GetBalancerInfo", in, out, opts...)
if err != nil {
return nil, err
}
@ -95,7 +90,25 @@ func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalan
func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) {
out := new(OverrideBalancerTargetResponse)
err := c.cc.Invoke(ctx, RoutingService_OverrideBalancerTarget_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/OverrideBalancerTarget", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *routingServiceClient) AddRule(ctx context.Context, in *AddRuleRequest, opts ...grpc.CallOption) (*AddRuleResponse, error) {
out := new(AddRuleResponse)
err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/AddRule", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *routingServiceClient) RemoveRule(ctx context.Context, in *RemoveRuleRequest, opts ...grpc.CallOption) (*RemoveRuleResponse, error) {
out := new(RemoveRuleResponse)
err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/RemoveRule", in, out, opts...)
if err != nil {
return nil, err
}
@ -110,6 +123,8 @@ type RoutingServiceServer interface {
TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error)
GetBalancerInfo(context.Context, *GetBalancerInfoRequest) (*GetBalancerInfoResponse, error)
OverrideBalancerTarget(context.Context, *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error)
AddRule(context.Context, *AddRuleRequest) (*AddRuleResponse, error)
RemoveRule(context.Context, *RemoveRuleRequest) (*RemoveRuleResponse, error)
mustEmbedUnimplementedRoutingServiceServer()
}
@ -129,6 +144,12 @@ func (UnimplementedRoutingServiceServer) GetBalancerInfo(context.Context, *GetBa
func (UnimplementedRoutingServiceServer) OverrideBalancerTarget(context.Context, *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method OverrideBalancerTarget not implemented")
}
func (UnimplementedRoutingServiceServer) AddRule(context.Context, *AddRuleRequest) (*AddRuleResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddRule not implemented")
}
func (UnimplementedRoutingServiceServer) RemoveRule(context.Context, *RemoveRuleRequest) (*RemoveRuleResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RemoveRule not implemented")
}
func (UnimplementedRoutingServiceServer) mustEmbedUnimplementedRoutingServiceServer() {}
// UnsafeRoutingServiceServer may be embedded to opt out of forward compatibility for this service.
@ -173,7 +194,7 @@ func _RoutingService_TestRoute_Handler(srv interface{}, ctx context.Context, dec
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: RoutingService_TestRoute_FullMethodName,
FullMethod: "/xray.app.router.command.RoutingService/TestRoute",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RoutingServiceServer).TestRoute(ctx, req.(*TestRouteRequest))
@ -191,7 +212,7 @@ func _RoutingService_GetBalancerInfo_Handler(srv interface{}, ctx context.Contex
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: RoutingService_GetBalancerInfo_FullMethodName,
FullMethod: "/xray.app.router.command.RoutingService/GetBalancerInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RoutingServiceServer).GetBalancerInfo(ctx, req.(*GetBalancerInfoRequest))
@ -209,7 +230,7 @@ func _RoutingService_OverrideBalancerTarget_Handler(srv interface{}, ctx context
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: RoutingService_OverrideBalancerTarget_FullMethodName,
FullMethod: "/xray.app.router.command.RoutingService/OverrideBalancerTarget",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RoutingServiceServer).OverrideBalancerTarget(ctx, req.(*OverrideBalancerTargetRequest))
@ -217,6 +238,42 @@ func _RoutingService_OverrideBalancerTarget_Handler(srv interface{}, ctx context
return interceptor(ctx, in, info, handler)
}
func _RoutingService_AddRule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddRuleRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RoutingServiceServer).AddRule(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/xray.app.router.command.RoutingService/AddRule",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RoutingServiceServer).AddRule(ctx, req.(*AddRuleRequest))
}
return interceptor(ctx, in, info, handler)
}
func _RoutingService_RemoveRule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RemoveRuleRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RoutingServiceServer).RemoveRule(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/xray.app.router.command.RoutingService/RemoveRule",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RoutingServiceServer).RemoveRule(ctx, req.(*RemoveRuleRequest))
}
return interceptor(ctx, in, info, handler)
}
// RoutingService_ServiceDesc is the grpc.ServiceDesc for RoutingService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -236,6 +293,14 @@ var RoutingService_ServiceDesc = grpc.ServiceDesc{
MethodName: "OverrideBalancerTarget",
Handler: _RoutingService_OverrideBalancerTarget_Handler,
},
{
MethodName: "AddRule",
Handler: _RoutingService_AddRule_Handler,
},
{
MethodName: "RemoveRule",
Handler: _RoutingService_RemoveRule_Handler,
},
},
Streams: []grpc.StreamDesc{
{