rls: Update rls protobufs. (#3562)
The `Target` field in the response has been deprecated in favor or `Targets` which specifies a list of possible targets. Pulled in the latest proto and updated code referencing it.
This commit is contained in:

committed by
GitHub

parent
a0cdc21e61
commit
c10d2c6f85
@ -62,7 +62,7 @@ func newRLSClient(cc *grpc.ClientConn, dialTarget string, rpcTimeout time.Durati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type lookupCallback func(target, headerData string, err error)
|
type lookupCallback func(targets []string, headerData string, err error)
|
||||||
|
|
||||||
// lookup starts a RouteLookup RPC in a separate goroutine and returns the
|
// lookup starts a RouteLookup RPC in a separate goroutine and returns the
|
||||||
// results (and error, if any) in the provided callback.
|
// results (and error, if any) in the provided callback.
|
||||||
@ -75,7 +75,7 @@ func (c *rlsClient) lookup(path string, keyMap map[string]string, cb lookupCallb
|
|||||||
TargetType: grpcTargetType,
|
TargetType: grpcTargetType,
|
||||||
KeyMap: keyMap,
|
KeyMap: keyMap,
|
||||||
})
|
})
|
||||||
cb(resp.GetTarget(), resp.GetHeaderData(), err)
|
cb(resp.GetTargets(), resp.GetHeaderData(), err)
|
||||||
cancel()
|
cancel()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -69,13 +69,13 @@ func TestLookupFailure(t *testing.T) {
|
|||||||
rlsClient := newRLSClient(cc, defaultDialTarget, defaultRPCTimeout)
|
rlsClient := newRLSClient(cc, defaultDialTarget, defaultRPCTimeout)
|
||||||
|
|
||||||
errCh := make(chan error)
|
errCh := make(chan error)
|
||||||
rlsClient.lookup("", nil, func(target, headerData string, err error) {
|
rlsClient.lookup("", nil, func(targets []string, headerData string, err error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
errCh <- errors.New("rlsClient.lookup() succeeded, should have failed")
|
errCh <- errors.New("rlsClient.lookup() succeeded, should have failed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if target != "" || headerData != "" {
|
if len(targets) != 0 || headerData != "" {
|
||||||
errCh <- fmt.Errorf("rlsClient.lookup() = (%s, %s), should be empty strings", target, headerData)
|
errCh <- fmt.Errorf("rlsClient.lookup() = (%v, %s), want (nil, \"\")", targets, headerData)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
errCh <- nil
|
errCh <- nil
|
||||||
@ -104,7 +104,7 @@ func TestLookupDeadlineExceeded(t *testing.T) {
|
|||||||
rlsClient := newRLSClient(cc, defaultDialTarget, 100*time.Millisecond)
|
rlsClient := newRLSClient(cc, defaultDialTarget, 100*time.Millisecond)
|
||||||
|
|
||||||
errCh := make(chan error)
|
errCh := make(chan error)
|
||||||
rlsClient.lookup("", nil, func(target, headerData string, err error) {
|
rlsClient.lookup("", nil, func(_ []string, _ string, err error) {
|
||||||
if st, ok := status.FromError(err); !ok || st.Code() != codes.DeadlineExceeded {
|
if st, ok := status.FromError(err); !ok || st.Code() != codes.DeadlineExceeded {
|
||||||
errCh <- fmt.Errorf("rlsClient.lookup() returned error: %v, want %v", err, codes.DeadlineExceeded)
|
errCh <- fmt.Errorf("rlsClient.lookup() returned error: %v, want %v", err, codes.DeadlineExceeded)
|
||||||
return
|
return
|
||||||
@ -130,9 +130,8 @@ func TestLookupSuccess(t *testing.T) {
|
|||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
const (
|
const (
|
||||||
rlsReqPath = "/service/method"
|
rlsReqPath = "/service/method"
|
||||||
rlsRespTarget = "us_east_1.firestore.googleapis.com"
|
wantHeaderData = "headerData"
|
||||||
rlsHeaderData = "headerData"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
rlsReqKeyMap := map[string]string{
|
rlsReqKeyMap := map[string]string{
|
||||||
@ -145,17 +144,18 @@ func TestLookupSuccess(t *testing.T) {
|
|||||||
TargetType: "grpc",
|
TargetType: "grpc",
|
||||||
KeyMap: rlsReqKeyMap,
|
KeyMap: rlsReqKeyMap,
|
||||||
}
|
}
|
||||||
|
wantRespTargets := []string{"us_east_1.firestore.googleapis.com"}
|
||||||
|
|
||||||
rlsClient := newRLSClient(cc, defaultDialTarget, defaultRPCTimeout)
|
rlsClient := newRLSClient(cc, defaultDialTarget, defaultRPCTimeout)
|
||||||
|
|
||||||
errCh := make(chan error)
|
errCh := make(chan error)
|
||||||
rlsClient.lookup(rlsReqPath, rlsReqKeyMap, func(t, hd string, err error) {
|
rlsClient.lookup(rlsReqPath, rlsReqKeyMap, func(targets []string, hd string, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errCh <- fmt.Errorf("rlsClient.Lookup() failed: %v", err)
|
errCh <- fmt.Errorf("rlsClient.Lookup() failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if t != rlsRespTarget || hd != rlsHeaderData {
|
if !cmp.Equal(targets, wantRespTargets) || hd != wantHeaderData {
|
||||||
errCh <- fmt.Errorf("rlsClient.lookup() = (%s, %s), want (%s, %s)", t, hd, rlsRespTarget, rlsHeaderData)
|
errCh <- fmt.Errorf("rlsClient.lookup() = (%v, %s), want (%v, %s)", targets, hd, wantRespTargets, wantHeaderData)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
errCh <- nil
|
errCh <- nil
|
||||||
@ -180,8 +180,8 @@ func TestLookupSuccess(t *testing.T) {
|
|||||||
// request.
|
// request.
|
||||||
server.ResponseChan <- fakeserver.Response{
|
server.ResponseChan <- fakeserver.Response{
|
||||||
Resp: &rlspb.RouteLookupResponse{
|
Resp: &rlspb.RouteLookupResponse{
|
||||||
Target: rlsRespTarget,
|
Targets: wantRespTargets,
|
||||||
HeaderData: rlsHeaderData,
|
HeaderData: wantHeaderData,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,14 @@ func (m *RouteLookupRequest) GetKeyMap() map[string]string {
|
|||||||
type RouteLookupResponse struct {
|
type RouteLookupResponse struct {
|
||||||
// Actual addressable entity to use for routing decision, using syntax
|
// Actual addressable entity to use for routing decision, using syntax
|
||||||
// requested by the request target_type.
|
// requested by the request target_type.
|
||||||
Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"`
|
// This field is deprecated in favor of the new "targets" field, below.
|
||||||
|
Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` // Deprecated: Do not use.
|
||||||
|
// Prioritized list (best one first) of addressable entities to use
|
||||||
|
// for routing, using syntax requested by the request target_type.
|
||||||
|
// The targets will be tried in order until a healthy one is found.
|
||||||
|
// If present, it should be used by proxy/gRPC client code instead of
|
||||||
|
// "target" (which is deprecated).
|
||||||
|
Targets []string `protobuf:"bytes,3,rep,name=targets,proto3" json:"targets,omitempty"`
|
||||||
// Optional header value to pass along to AFE in the X-Google-RLS-Data header.
|
// Optional header value to pass along to AFE in the X-Google-RLS-Data header.
|
||||||
// Cached with "target" and sent with all requests that match the request key.
|
// Cached with "target" and sent with all requests that match the request key.
|
||||||
// Allows the RLS to pass its work product to the eventual target.
|
// Allows the RLS to pass its work product to the eventual target.
|
||||||
@ -132,6 +139,7 @@ func (m *RouteLookupResponse) XXX_DiscardUnknown() {
|
|||||||
|
|
||||||
var xxx_messageInfo_RouteLookupResponse proto.InternalMessageInfo
|
var xxx_messageInfo_RouteLookupResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
|
// Deprecated: Do not use.
|
||||||
func (m *RouteLookupResponse) GetTarget() string {
|
func (m *RouteLookupResponse) GetTarget() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Target
|
return m.Target
|
||||||
@ -139,6 +147,13 @@ func (m *RouteLookupResponse) GetTarget() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *RouteLookupResponse) GetTargets() []string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Targets
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *RouteLookupResponse) GetHeaderData() string {
|
func (m *RouteLookupResponse) GetHeaderData() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.HeaderData
|
return m.HeaderData
|
||||||
@ -155,37 +170,38 @@ func init() {
|
|||||||
func init() { proto.RegisterFile("grpc/rls/grpc_lookup_v1/rls.proto", fileDescriptor_5fe9649e373b9d12) }
|
func init() { proto.RegisterFile("grpc/rls/grpc_lookup_v1/rls.proto", fileDescriptor_5fe9649e373b9d12) }
|
||||||
|
|
||||||
var fileDescriptor_5fe9649e373b9d12 = []byte{
|
var fileDescriptor_5fe9649e373b9d12 = []byte{
|
||||||
// 325 bytes of a gzipped FileDescriptorProto
|
// 345 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x4b, 0xc3, 0x30,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x4b, 0xeb, 0x40,
|
||||||
0x14, 0xc6, 0xed, 0x36, 0xa7, 0xbe, 0x82, 0x68, 0x14, 0x29, 0xbb, 0x38, 0xeb, 0x65, 0x07, 0xc9,
|
0x10, 0xc6, 0x5f, 0x9a, 0xbe, 0xf4, 0x75, 0x02, 0x8f, 0xf7, 0x56, 0x91, 0xd0, 0x8b, 0x35, 0x5e,
|
||||||
0xd8, 0xbc, 0xa8, 0xc7, 0xa1, 0x78, 0xd0, 0xc9, 0xa8, 0x1e, 0xc4, 0x4b, 0x89, 0xdb, 0x23, 0x1b,
|
0x7a, 0x90, 0x2d, 0xad, 0x17, 0xf5, 0x58, 0x14, 0x0f, 0x5a, 0x28, 0xd1, 0x83, 0x78, 0x09, 0x6b,
|
||||||
0xad, 0x4d, 0x4c, 0xd3, 0x42, 0xff, 0x60, 0xff, 0x0f, 0x49, 0x52, 0x61, 0x9d, 0xa0, 0xb7, 0xf7,
|
0x3b, 0xa4, 0x25, 0x6b, 0x76, 0xdd, 0xdd, 0x04, 0xf2, 0x07, 0xfb, 0x7f, 0x48, 0x76, 0x23, 0xb4,
|
||||||
0xfd, 0xde, 0x23, 0xf9, 0xbe, 0xe4, 0xc1, 0x19, 0x57, 0x72, 0x3e, 0x54, 0x69, 0x3e, 0x34, 0x45,
|
0x15, 0xf4, 0xf6, 0x7d, 0xbf, 0x19, 0xb2, 0xdf, 0x4c, 0x06, 0x4e, 0x32, 0x25, 0x97, 0x63, 0xc5,
|
||||||
0x9c, 0x0a, 0x91, 0x14, 0x32, 0x2e, 0x47, 0x06, 0x51, 0xa9, 0x84, 0x16, 0x64, 0xdf, 0x74, 0xa8,
|
0xf5, 0xb8, 0x11, 0x29, 0x17, 0x22, 0x2f, 0x65, 0x5a, 0x4d, 0x1a, 0x44, 0xa5, 0x12, 0x46, 0x90,
|
||||||
0xeb, 0xd0, 0x72, 0x14, 0x7e, 0x79, 0x40, 0x22, 0x51, 0x68, 0x7c, 0xb4, 0x28, 0xc2, 0xcf, 0x02,
|
0xbf, 0x4d, 0x85, 0xba, 0x0a, 0xad, 0x26, 0xf1, 0xbb, 0x07, 0x24, 0x11, 0xa5, 0xc1, 0x7b, 0x8b,
|
||||||
0x73, 0x4d, 0x4e, 0xa0, 0x9b, 0xa3, 0x2a, 0x51, 0x05, 0x5e, 0xdf, 0x1b, 0xec, 0x45, 0xb5, 0x22,
|
0x12, 0x7c, 0x2b, 0x51, 0x1b, 0x72, 0x04, 0x81, 0x46, 0x55, 0xa1, 0x8a, 0xbc, 0xa1, 0x37, 0xea,
|
||||||
0x04, 0x3a, 0x92, 0xe9, 0x65, 0xd0, 0xb2, 0xd4, 0xd6, 0xe4, 0x14, 0x7c, 0xcd, 0x14, 0x47, 0x1d,
|
0x27, 0xad, 0x23, 0x04, 0xba, 0x92, 0x99, 0x75, 0xd4, 0xb1, 0xd4, 0x6a, 0x72, 0x0c, 0xa1, 0x61,
|
||||||
0xeb, 0x4a, 0x62, 0xd0, 0xb6, 0x2d, 0x70, 0xe8, 0xa5, 0x92, 0x48, 0xee, 0x61, 0x27, 0xc1, 0x2a,
|
0x2a, 0x43, 0x93, 0x9a, 0x5a, 0x62, 0xe4, 0xdb, 0x12, 0x38, 0xf4, 0x58, 0x4b, 0x24, 0xb7, 0xd0,
|
||||||
0xfe, 0x60, 0x32, 0xe8, 0xf4, 0xdb, 0x03, 0x7f, 0x4c, 0x69, 0xd3, 0x05, 0xfd, 0xed, 0x80, 0x3e,
|
0xcb, 0xb1, 0x4e, 0x5f, 0x99, 0x8c, 0xba, 0x43, 0x7f, 0x14, 0x4e, 0x29, 0xdd, 0x4d, 0x41, 0xbf,
|
||||||
0x60, 0x35, 0x65, 0xf2, 0x2e, 0xd3, 0xaa, 0x8a, 0xba, 0x89, 0x15, 0xbd, 0x6b, 0xf0, 0xd7, 0x30,
|
0x26, 0xa0, 0x77, 0x58, 0xcf, 0x99, 0xbc, 0x29, 0x8c, 0xaa, 0x93, 0x20, 0xb7, 0x66, 0x70, 0x09,
|
||||||
0x39, 0x80, 0x76, 0x82, 0x55, 0xed, 0xd0, 0x94, 0xe4, 0x18, 0xb6, 0x4b, 0x96, 0x16, 0x58, 0xfb,
|
0xe1, 0x16, 0x26, 0xff, 0xc0, 0xcf, 0xb1, 0x6e, 0x13, 0x36, 0x92, 0x1c, 0xc2, 0xef, 0x8a, 0xf1,
|
||||||
0x73, 0xe2, 0xa6, 0x75, 0xe5, 0x85, 0x4f, 0x70, 0xd4, 0xb8, 0x24, 0x97, 0x22, 0xcb, 0xd1, 0xe4,
|
0x12, 0xdb, 0x7c, 0xce, 0x5c, 0x75, 0x2e, 0xbc, 0x98, 0xc3, 0xc1, 0xce, 0x23, 0x5a, 0x8a, 0x42,
|
||||||
0x74, 0x46, 0x7f, 0x72, 0x3a, 0x65, 0x32, 0x2d, 0x91, 0x2d, 0x50, 0xc5, 0x0b, 0xa6, 0x59, 0x7d,
|
0x23, 0x19, 0x40, 0xe0, 0x82, 0xba, 0xaf, 0xcc, 0x3a, 0x91, 0x97, 0xb4, 0x84, 0x44, 0xd0, 0x73,
|
||||||
0x1c, 0x38, 0x74, 0xcb, 0x34, 0x1b, 0x67, 0x8d, 0x67, 0x7b, 0x46, 0x55, 0xae, 0xe6, 0x48, 0x5e,
|
0x4a, 0x47, 0xfe, 0xd0, 0x1f, 0xf5, 0x93, 0x4f, 0xdb, 0x4c, 0xbc, 0x46, 0xb6, 0x42, 0x95, 0xae,
|
||||||
0xc1, 0x5f, 0xa3, 0x24, 0xfc, 0x3f, 0x67, 0xef, 0xfc, 0xcf, 0x19, 0x67, 0x33, 0xdc, 0x9a, 0x4c,
|
0x98, 0x61, 0xed, 0x63, 0xe0, 0xd0, 0x35, 0x33, 0x6c, 0x5a, 0xec, 0x2c, 0xf5, 0x01, 0x55, 0xb5,
|
||||||
0xe1, 0x70, 0x25, 0x36, 0x46, 0x27, 0xbb, 0x51, 0x9a, 0xcf, 0xcc, 0xb7, 0xce, 0xbc, 0xb7, 0x0b,
|
0x59, 0x22, 0x79, 0x82, 0x70, 0x8b, 0x92, 0xf8, 0xe7, 0x2d, 0x0c, 0x4e, 0xbf, 0xed, 0x71, 0x43,
|
||||||
0x2e, 0x04, 0x4f, 0x91, 0x72, 0x91, 0xb2, 0x8c, 0x53, 0xa1, 0xb8, 0x5d, 0x82, 0xa1, 0x9b, 0xde,
|
0xc4, 0xbf, 0x66, 0x73, 0xf8, 0xbf, 0x11, 0x7b, 0xad, 0xb3, 0x3f, 0x09, 0xd7, 0x8b, 0xe6, 0xa7,
|
||||||
0x58, 0x88, 0xf7, 0xae, 0xdd, 0x86, 0xcb, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0x10, 0x2d,
|
0x2f, 0xbc, 0xe7, 0xb3, 0x4c, 0x88, 0x8c, 0x23, 0xcd, 0x04, 0x67, 0x45, 0x46, 0x85, 0xca, 0xec,
|
||||||
0xb5, 0x32, 0x02, 0x00, 0x00,
|
0x89, 0x8c, 0x5d, 0xf7, 0xde, 0xb9, 0xbc, 0x04, 0xf6, 0x56, 0xce, 0x3f, 0x02, 0x00, 0x00, 0xff,
|
||||||
|
0xff, 0xb4, 0xe3, 0xe2, 0xd0, 0x50, 0x02, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var _ context.Context
|
var _ context.Context
|
||||||
var _ grpc.ClientConn
|
var _ grpc.ClientConnInterface
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// is compatible with the grpc package it is being compiled against.
|
// is compatible with the grpc package it is being compiled against.
|
||||||
const _ = grpc.SupportPackageIsVersion4
|
const _ = grpc.SupportPackageIsVersion6
|
||||||
|
|
||||||
// RouteLookupServiceClient is the client API for RouteLookupService service.
|
// RouteLookupServiceClient is the client API for RouteLookupService service.
|
||||||
//
|
//
|
||||||
@ -196,10 +212,10 @@ type RouteLookupServiceClient interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type routeLookupServiceClient struct {
|
type routeLookupServiceClient struct {
|
||||||
cc *grpc.ClientConn
|
cc grpc.ClientConnInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRouteLookupServiceClient(cc *grpc.ClientConn) RouteLookupServiceClient {
|
func NewRouteLookupServiceClient(cc grpc.ClientConnInterface) RouteLookupServiceClient {
|
||||||
return &routeLookupServiceClient{cc}
|
return &routeLookupServiceClient{cc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ type GrpcKeyBuilder struct {
|
|||||||
Names []*GrpcKeyBuilder_Name `protobuf:"bytes,1,rep,name=names,proto3" json:"names,omitempty"`
|
Names []*GrpcKeyBuilder_Name `protobuf:"bytes,1,rep,name=names,proto3" json:"names,omitempty"`
|
||||||
// Extract keys from all listed headers.
|
// Extract keys from all listed headers.
|
||||||
// For gRPC, it is an error to specify "required_match" on the NameMatcher
|
// For gRPC, it is an error to specify "required_match" on the NameMatcher
|
||||||
// protos, and we ignore it if set.
|
// protos.
|
||||||
Headers []*NameMatcher `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"`
|
Headers []*NameMatcher `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
@ -379,7 +379,7 @@ type RouteLookupConfig struct {
|
|||||||
// Defaults to 10 seconds if not specified.
|
// Defaults to 10 seconds if not specified.
|
||||||
LookupServiceTimeout *duration.Duration `protobuf:"bytes,4,opt,name=lookup_service_timeout,json=lookupServiceTimeout,proto3" json:"lookup_service_timeout,omitempty"`
|
LookupServiceTimeout *duration.Duration `protobuf:"bytes,4,opt,name=lookup_service_timeout,json=lookupServiceTimeout,proto3" json:"lookup_service_timeout,omitempty"`
|
||||||
// How long are responses valid for (like HTTP Cache-Control).
|
// How long are responses valid for (like HTTP Cache-Control).
|
||||||
// If omitted (i.e. 0), responses are considered not to be cacheable.
|
// If omitted or zero, the longest valid cache time is used.
|
||||||
// This value is clamped to 5 minutes to avoid unflushable bad responses.
|
// This value is clamped to 5 minutes to avoid unflushable bad responses.
|
||||||
MaxAge *duration.Duration `protobuf:"bytes,5,opt,name=max_age,json=maxAge,proto3" json:"max_age,omitempty"`
|
MaxAge *duration.Duration `protobuf:"bytes,5,opt,name=max_age,json=maxAge,proto3" json:"max_age,omitempty"`
|
||||||
// After a response has been in the client cache for this amount of time
|
// After a response has been in the client cache for this amount of time
|
||||||
|
Reference in New Issue
Block a user