From fca4f608aa1c05a6dfa57854a25114fb9418961d Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Fri, 25 Aug 2017 12:17:20 -0700 Subject: [PATCH] fix grpclb protos to not cause re-registration of types --- grpclb.go | 30 +- grpclb/grpc_lb_v1/grpclb.pb.go | 740 ------------------ .../messages/messages.pb.go} | 100 ++- .../{grpclb.proto => messages/messages.proto} | 6 - grpclb/grpc_lb_v1/service/service.pb.go | 154 ++++ grpclb/grpc_lb_v1/service/service.proto | 25 + grpclb/grpclb_test.go | 99 +-- 7 files changed, 293 insertions(+), 861 deletions(-) delete mode 100644 grpclb/grpc_lb_v1/grpclb.pb.go rename grpclb/{messages_only/grpc_lb_v1/grpclb.pb.go => grpc_lb_v1/messages/messages.pb.go} (82%) rename grpclb/grpc_lb_v1/{grpclb.proto => messages/messages.proto} (97%) create mode 100644 grpclb/grpc_lb_v1/service/service.pb.go create mode 100644 grpclb/grpc_lb_v1/service/service.proto diff --git a/grpclb.go b/grpclb.go index 363053fe04a8..a61892edd426 100644 --- a/grpclb.go +++ b/grpclb.go @@ -28,7 +28,7 @@ import ( "golang.org/x/net/context" "google.golang.org/grpc/codes" - lbpb "google.golang.org/grpc/grpclb/messages_only/grpc_lb_v1" + lbmpb "google.golang.org/grpc/grpclb/grpc_lb_v1/messages" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/naming" @@ -59,12 +59,12 @@ type balanceLoadClientStream struct { ClientStream } -func (x *balanceLoadClientStream) Send(m *lbpb.LoadBalanceRequest) error { +func (x *balanceLoadClientStream) Send(m *lbmpb.LoadBalanceRequest) error { return x.ClientStream.SendMsg(m) } -func (x *balanceLoadClientStream) Recv() (*lbpb.LoadBalanceResponse, error) { - m := new(lbpb.LoadBalanceResponse) +func (x *balanceLoadClientStream) Recv() (*lbmpb.LoadBalanceResponse, error) { + m := new(lbmpb.LoadBalanceResponse) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -111,7 +111,7 @@ type balancer struct { expTimer *time.Timer rand *rand.Rand - clientStats lbpb.ClientStats + clientStats lbmpb.ClientStats } func (b *balancer) watchAddrUpdates(w naming.Watcher, ch chan []remoteBalancerInfo) error { @@ -196,14 +196,14 @@ func (b *balancer) serverListExpire(seq int) { b.addrCh <- nil } -func convertDuration(d *lbpb.Duration) time.Duration { +func convertDuration(d *lbmpb.Duration) time.Duration { if d == nil { return 0 } return time.Duration(d.Seconds)*time.Second + time.Duration(d.Nanos)*time.Nanosecond } -func (b *balancer) processServerList(l *lbpb.ServerList, seq int) { +func (b *balancer) processServerList(l *lbmpb.ServerList, seq int) { if l == nil { return } @@ -267,15 +267,15 @@ func (b *balancer) sendLoadReport(s *balanceLoadClientStream, interval time.Dura } b.mu.Lock() stats := b.clientStats - b.clientStats = lbpb.ClientStats{} // Clear the stats. + b.clientStats = lbmpb.ClientStats{} // Clear the stats. b.mu.Unlock() t := time.Now() - stats.Timestamp = &lbpb.Timestamp{ + stats.Timestamp = &lbmpb.Timestamp{ Seconds: t.Unix(), Nanos: int32(t.Nanosecond()), } - if err := s.Send(&lbpb.LoadBalanceRequest{ - LoadBalanceRequestType: &lbpb.LoadBalanceRequest_ClientStats{ + if err := s.Send(&lbmpb.LoadBalanceRequest{ + LoadBalanceRequestType: &lbmpb.LoadBalanceRequest_ClientStats{ ClientStats: &stats, }, }); err != nil { @@ -299,9 +299,9 @@ func (b *balancer) callRemoteBalancer(lbc *loadBalancerClient, seq int) (retry b return } b.mu.Unlock() - initReq := &lbpb.LoadBalanceRequest{ - LoadBalanceRequestType: &lbpb.LoadBalanceRequest_InitialRequest{ - InitialRequest: &lbpb.InitialLoadBalanceRequest{ + initReq := &lbmpb.LoadBalanceRequest{ + LoadBalanceRequestType: &lbmpb.LoadBalanceRequest_InitialRequest{ + InitialRequest: &lbmpb.InitialLoadBalanceRequest{ Name: b.target, }, }, @@ -331,7 +331,7 @@ func (b *balancer) callRemoteBalancer(lbc *loadBalancerClient, seq int) (retry b streamDone := make(chan struct{}) defer close(streamDone) b.mu.Lock() - b.clientStats = lbpb.ClientStats{} // Clear client stats. + b.clientStats = lbmpb.ClientStats{} // Clear client stats. b.mu.Unlock() if d := convertDuration(initResp.ClientStatsReportInterval); d > 0 { go b.sendLoadReport(stream, d, streamDone) diff --git a/grpclb/grpc_lb_v1/grpclb.pb.go b/grpclb/grpc_lb_v1/grpclb.pb.go deleted file mode 100644 index 67c99e39c4ae..000000000000 --- a/grpclb/grpc_lb_v1/grpclb.pb.go +++ /dev/null @@ -1,740 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc_lb_v1/grpclb.proto - -/* -Package grpc_lb_v1 is a generated protocol buffer package. - -It is generated from these files: - grpc_lb_v1/grpclb.proto - -It has these top-level messages: - Duration - Timestamp - LoadBalanceRequest - InitialLoadBalanceRequest - ClientStats - LoadBalanceResponse - InitialLoadBalanceResponse - ServerList - Server -*/ -package grpc_lb_v1 - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -import ( - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Duration struct { - // Signed seconds of the span of time. Must be from -315,576,000,000 - // to +315,576,000,000 inclusive. - Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` - // Signed fractions of a second at nanosecond resolution of the span - // of time. Durations less than one second are represented with a 0 - // `seconds` field and a positive or negative `nanos` field. For durations - // of one second or more, a non-zero value for the `nanos` field must be - // of the same sign as the `seconds` field. Must be from -999,999,999 - // to +999,999,999 inclusive. - Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` -} - -func (m *Duration) Reset() { *m = Duration{} } -func (m *Duration) String() string { return proto.CompactTextString(m) } -func (*Duration) ProtoMessage() {} -func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *Duration) GetSeconds() int64 { - if m != nil { - return m.Seconds - } - return 0 -} - -func (m *Duration) GetNanos() int32 { - if m != nil { - return m.Nanos - } - return 0 -} - -type Timestamp struct { - // Represents seconds of UTC time since Unix epoch - // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - // 9999-12-31T23:59:59Z inclusive. - Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` - // Non-negative fractions of a second at nanosecond resolution. Negative - // second values with fractions must still have non-negative nanos values - // that count forward in time. Must be from 0 to 999,999,999 - // inclusive. - Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` -} - -func (m *Timestamp) Reset() { *m = Timestamp{} } -func (m *Timestamp) String() string { return proto.CompactTextString(m) } -func (*Timestamp) ProtoMessage() {} -func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -func (m *Timestamp) GetSeconds() int64 { - if m != nil { - return m.Seconds - } - return 0 -} - -func (m *Timestamp) GetNanos() int32 { - if m != nil { - return m.Nanos - } - return 0 -} - -type LoadBalanceRequest struct { - // Types that are valid to be assigned to LoadBalanceRequestType: - // *LoadBalanceRequest_InitialRequest - // *LoadBalanceRequest_ClientStats - LoadBalanceRequestType isLoadBalanceRequest_LoadBalanceRequestType `protobuf_oneof:"load_balance_request_type"` -} - -func (m *LoadBalanceRequest) Reset() { *m = LoadBalanceRequest{} } -func (m *LoadBalanceRequest) String() string { return proto.CompactTextString(m) } -func (*LoadBalanceRequest) ProtoMessage() {} -func (*LoadBalanceRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } - -type isLoadBalanceRequest_LoadBalanceRequestType interface { - isLoadBalanceRequest_LoadBalanceRequestType() -} - -type LoadBalanceRequest_InitialRequest struct { - InitialRequest *InitialLoadBalanceRequest `protobuf:"bytes,1,opt,name=initial_request,json=initialRequest,oneof"` -} -type LoadBalanceRequest_ClientStats struct { - ClientStats *ClientStats `protobuf:"bytes,2,opt,name=client_stats,json=clientStats,oneof"` -} - -func (*LoadBalanceRequest_InitialRequest) isLoadBalanceRequest_LoadBalanceRequestType() {} -func (*LoadBalanceRequest_ClientStats) isLoadBalanceRequest_LoadBalanceRequestType() {} - -func (m *LoadBalanceRequest) GetLoadBalanceRequestType() isLoadBalanceRequest_LoadBalanceRequestType { - if m != nil { - return m.LoadBalanceRequestType - } - return nil -} - -func (m *LoadBalanceRequest) GetInitialRequest() *InitialLoadBalanceRequest { - if x, ok := m.GetLoadBalanceRequestType().(*LoadBalanceRequest_InitialRequest); ok { - return x.InitialRequest - } - return nil -} - -func (m *LoadBalanceRequest) GetClientStats() *ClientStats { - if x, ok := m.GetLoadBalanceRequestType().(*LoadBalanceRequest_ClientStats); ok { - return x.ClientStats - } - return nil -} - -// XXX_OneofFuncs is for the internal use of the proto package. -func (*LoadBalanceRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _LoadBalanceRequest_OneofMarshaler, _LoadBalanceRequest_OneofUnmarshaler, _LoadBalanceRequest_OneofSizer, []interface{}{ - (*LoadBalanceRequest_InitialRequest)(nil), - (*LoadBalanceRequest_ClientStats)(nil), - } -} - -func _LoadBalanceRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*LoadBalanceRequest) - // load_balance_request_type - switch x := m.LoadBalanceRequestType.(type) { - case *LoadBalanceRequest_InitialRequest: - b.EncodeVarint(1<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.InitialRequest); err != nil { - return err - } - case *LoadBalanceRequest_ClientStats: - b.EncodeVarint(2<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.ClientStats); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("LoadBalanceRequest.LoadBalanceRequestType has unexpected type %T", x) - } - return nil -} - -func _LoadBalanceRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*LoadBalanceRequest) - switch tag { - case 1: // load_balance_request_type.initial_request - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(InitialLoadBalanceRequest) - err := b.DecodeMessage(msg) - m.LoadBalanceRequestType = &LoadBalanceRequest_InitialRequest{msg} - return true, err - case 2: // load_balance_request_type.client_stats - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(ClientStats) - err := b.DecodeMessage(msg) - m.LoadBalanceRequestType = &LoadBalanceRequest_ClientStats{msg} - return true, err - default: - return false, nil - } -} - -func _LoadBalanceRequest_OneofSizer(msg proto.Message) (n int) { - m := msg.(*LoadBalanceRequest) - // load_balance_request_type - switch x := m.LoadBalanceRequestType.(type) { - case *LoadBalanceRequest_InitialRequest: - s := proto.Size(x.InitialRequest) - n += proto.SizeVarint(1<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(s)) - n += s - case *LoadBalanceRequest_ClientStats: - s := proto.Size(x.ClientStats) - n += proto.SizeVarint(2<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - -type InitialLoadBalanceRequest struct { - // Name of load balanced service (IE, balancer.service.com) - // length should be less than 256 bytes. - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` -} - -func (m *InitialLoadBalanceRequest) Reset() { *m = InitialLoadBalanceRequest{} } -func (m *InitialLoadBalanceRequest) String() string { return proto.CompactTextString(m) } -func (*InitialLoadBalanceRequest) ProtoMessage() {} -func (*InitialLoadBalanceRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } - -func (m *InitialLoadBalanceRequest) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -// Contains client level statistics that are useful to load balancing. Each -// count except the timestamp should be reset to zero after reporting the stats. -type ClientStats struct { - // The timestamp of generating the report. - Timestamp *Timestamp `protobuf:"bytes,1,opt,name=timestamp" json:"timestamp,omitempty"` - // The total number of RPCs that started. - NumCallsStarted int64 `protobuf:"varint,2,opt,name=num_calls_started,json=numCallsStarted" json:"num_calls_started,omitempty"` - // The total number of RPCs that finished. - NumCallsFinished int64 `protobuf:"varint,3,opt,name=num_calls_finished,json=numCallsFinished" json:"num_calls_finished,omitempty"` - // The total number of RPCs that were dropped by the client because of rate - // limiting. - NumCallsFinishedWithDropForRateLimiting int64 `protobuf:"varint,4,opt,name=num_calls_finished_with_drop_for_rate_limiting,json=numCallsFinishedWithDropForRateLimiting" json:"num_calls_finished_with_drop_for_rate_limiting,omitempty"` - // The total number of RPCs that were dropped by the client because of load - // balancing. - NumCallsFinishedWithDropForLoadBalancing int64 `protobuf:"varint,5,opt,name=num_calls_finished_with_drop_for_load_balancing,json=numCallsFinishedWithDropForLoadBalancing" json:"num_calls_finished_with_drop_for_load_balancing,omitempty"` - // The total number of RPCs that failed to reach a server except dropped RPCs. - NumCallsFinishedWithClientFailedToSend int64 `protobuf:"varint,6,opt,name=num_calls_finished_with_client_failed_to_send,json=numCallsFinishedWithClientFailedToSend" json:"num_calls_finished_with_client_failed_to_send,omitempty"` - // The total number of RPCs that finished and are known to have been received - // by a server. - NumCallsFinishedKnownReceived int64 `protobuf:"varint,7,opt,name=num_calls_finished_known_received,json=numCallsFinishedKnownReceived" json:"num_calls_finished_known_received,omitempty"` -} - -func (m *ClientStats) Reset() { *m = ClientStats{} } -func (m *ClientStats) String() string { return proto.CompactTextString(m) } -func (*ClientStats) ProtoMessage() {} -func (*ClientStats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } - -func (m *ClientStats) GetTimestamp() *Timestamp { - if m != nil { - return m.Timestamp - } - return nil -} - -func (m *ClientStats) GetNumCallsStarted() int64 { - if m != nil { - return m.NumCallsStarted - } - return 0 -} - -func (m *ClientStats) GetNumCallsFinished() int64 { - if m != nil { - return m.NumCallsFinished - } - return 0 -} - -func (m *ClientStats) GetNumCallsFinishedWithDropForRateLimiting() int64 { - if m != nil { - return m.NumCallsFinishedWithDropForRateLimiting - } - return 0 -} - -func (m *ClientStats) GetNumCallsFinishedWithDropForLoadBalancing() int64 { - if m != nil { - return m.NumCallsFinishedWithDropForLoadBalancing - } - return 0 -} - -func (m *ClientStats) GetNumCallsFinishedWithClientFailedToSend() int64 { - if m != nil { - return m.NumCallsFinishedWithClientFailedToSend - } - return 0 -} - -func (m *ClientStats) GetNumCallsFinishedKnownReceived() int64 { - if m != nil { - return m.NumCallsFinishedKnownReceived - } - return 0 -} - -type LoadBalanceResponse struct { - // Types that are valid to be assigned to LoadBalanceResponseType: - // *LoadBalanceResponse_InitialResponse - // *LoadBalanceResponse_ServerList - LoadBalanceResponseType isLoadBalanceResponse_LoadBalanceResponseType `protobuf_oneof:"load_balance_response_type"` -} - -func (m *LoadBalanceResponse) Reset() { *m = LoadBalanceResponse{} } -func (m *LoadBalanceResponse) String() string { return proto.CompactTextString(m) } -func (*LoadBalanceResponse) ProtoMessage() {} -func (*LoadBalanceResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } - -type isLoadBalanceResponse_LoadBalanceResponseType interface { - isLoadBalanceResponse_LoadBalanceResponseType() -} - -type LoadBalanceResponse_InitialResponse struct { - InitialResponse *InitialLoadBalanceResponse `protobuf:"bytes,1,opt,name=initial_response,json=initialResponse,oneof"` -} -type LoadBalanceResponse_ServerList struct { - ServerList *ServerList `protobuf:"bytes,2,opt,name=server_list,json=serverList,oneof"` -} - -func (*LoadBalanceResponse_InitialResponse) isLoadBalanceResponse_LoadBalanceResponseType() {} -func (*LoadBalanceResponse_ServerList) isLoadBalanceResponse_LoadBalanceResponseType() {} - -func (m *LoadBalanceResponse) GetLoadBalanceResponseType() isLoadBalanceResponse_LoadBalanceResponseType { - if m != nil { - return m.LoadBalanceResponseType - } - return nil -} - -func (m *LoadBalanceResponse) GetInitialResponse() *InitialLoadBalanceResponse { - if x, ok := m.GetLoadBalanceResponseType().(*LoadBalanceResponse_InitialResponse); ok { - return x.InitialResponse - } - return nil -} - -func (m *LoadBalanceResponse) GetServerList() *ServerList { - if x, ok := m.GetLoadBalanceResponseType().(*LoadBalanceResponse_ServerList); ok { - return x.ServerList - } - return nil -} - -// XXX_OneofFuncs is for the internal use of the proto package. -func (*LoadBalanceResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _LoadBalanceResponse_OneofMarshaler, _LoadBalanceResponse_OneofUnmarshaler, _LoadBalanceResponse_OneofSizer, []interface{}{ - (*LoadBalanceResponse_InitialResponse)(nil), - (*LoadBalanceResponse_ServerList)(nil), - } -} - -func _LoadBalanceResponse_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*LoadBalanceResponse) - // load_balance_response_type - switch x := m.LoadBalanceResponseType.(type) { - case *LoadBalanceResponse_InitialResponse: - b.EncodeVarint(1<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.InitialResponse); err != nil { - return err - } - case *LoadBalanceResponse_ServerList: - b.EncodeVarint(2<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.ServerList); err != nil { - return err - } - case nil: - default: - return fmt.Errorf("LoadBalanceResponse.LoadBalanceResponseType has unexpected type %T", x) - } - return nil -} - -func _LoadBalanceResponse_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*LoadBalanceResponse) - switch tag { - case 1: // load_balance_response_type.initial_response - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(InitialLoadBalanceResponse) - err := b.DecodeMessage(msg) - m.LoadBalanceResponseType = &LoadBalanceResponse_InitialResponse{msg} - return true, err - case 2: // load_balance_response_type.server_list - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - msg := new(ServerList) - err := b.DecodeMessage(msg) - m.LoadBalanceResponseType = &LoadBalanceResponse_ServerList{msg} - return true, err - default: - return false, nil - } -} - -func _LoadBalanceResponse_OneofSizer(msg proto.Message) (n int) { - m := msg.(*LoadBalanceResponse) - // load_balance_response_type - switch x := m.LoadBalanceResponseType.(type) { - case *LoadBalanceResponse_InitialResponse: - s := proto.Size(x.InitialResponse) - n += proto.SizeVarint(1<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(s)) - n += s - case *LoadBalanceResponse_ServerList: - s := proto.Size(x.ServerList) - n += proto.SizeVarint(2<<3 | proto.WireBytes) - n += proto.SizeVarint(uint64(s)) - n += s - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n -} - -type InitialLoadBalanceResponse struct { - // This is an application layer redirect that indicates the client should use - // the specified server for load balancing. When this field is non-empty in - // the response, the client should open a separate connection to the - // load_balancer_delegate and call the BalanceLoad method. Its length should - // be less than 64 bytes. - LoadBalancerDelegate string `protobuf:"bytes,1,opt,name=load_balancer_delegate,json=loadBalancerDelegate" json:"load_balancer_delegate,omitempty"` - // This interval defines how often the client should send the client stats - // to the load balancer. Stats should only be reported when the duration is - // positive. - ClientStatsReportInterval *Duration `protobuf:"bytes,2,opt,name=client_stats_report_interval,json=clientStatsReportInterval" json:"client_stats_report_interval,omitempty"` -} - -func (m *InitialLoadBalanceResponse) Reset() { *m = InitialLoadBalanceResponse{} } -func (m *InitialLoadBalanceResponse) String() string { return proto.CompactTextString(m) } -func (*InitialLoadBalanceResponse) ProtoMessage() {} -func (*InitialLoadBalanceResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } - -func (m *InitialLoadBalanceResponse) GetLoadBalancerDelegate() string { - if m != nil { - return m.LoadBalancerDelegate - } - return "" -} - -func (m *InitialLoadBalanceResponse) GetClientStatsReportInterval() *Duration { - if m != nil { - return m.ClientStatsReportInterval - } - return nil -} - -type ServerList struct { - // Contains a list of servers selected by the load balancer. The list will - // be updated when server resolutions change or as needed to balance load - // across more servers. The client should consume the server list in order - // unless instructed otherwise via the client_config. - Servers []*Server `protobuf:"bytes,1,rep,name=servers" json:"servers,omitempty"` - // Indicates the amount of time that the client should consider this server - // list as valid. It may be considered stale after waiting this interval of - // time after receiving the list. If the interval is not positive, the - // client can assume the list is valid until the next list is received. - ExpirationInterval *Duration `protobuf:"bytes,3,opt,name=expiration_interval,json=expirationInterval" json:"expiration_interval,omitempty"` -} - -func (m *ServerList) Reset() { *m = ServerList{} } -func (m *ServerList) String() string { return proto.CompactTextString(m) } -func (*ServerList) ProtoMessage() {} -func (*ServerList) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } - -func (m *ServerList) GetServers() []*Server { - if m != nil { - return m.Servers - } - return nil -} - -func (m *ServerList) GetExpirationInterval() *Duration { - if m != nil { - return m.ExpirationInterval - } - return nil -} - -// Contains server information. When none of the [drop_for_*] fields are true, -// use the other fields. When drop_for_rate_limiting is true, ignore all other -// fields. Use drop_for_load_balancing only when it is true and -// drop_for_rate_limiting is false. -type Server struct { - // A resolved address for the server, serialized in network-byte-order. It may - // either be an IPv4 or IPv6 address. - IpAddress []byte `protobuf:"bytes,1,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"` - // A resolved port number for the server. - Port int32 `protobuf:"varint,2,opt,name=port" json:"port,omitempty"` - // An opaque but printable token given to the frontend for each pick. All - // frontend requests for that pick must include the token in its initial - // metadata. The token is used by the backend to verify the request and to - // allow the backend to report load to the gRPC LB system. - // - // Its length is variable but less than 50 bytes. - LoadBalanceToken string `protobuf:"bytes,3,opt,name=load_balance_token,json=loadBalanceToken" json:"load_balance_token,omitempty"` - // Indicates whether this particular request should be dropped by the client - // for rate limiting. - DropForRateLimiting bool `protobuf:"varint,4,opt,name=drop_for_rate_limiting,json=dropForRateLimiting" json:"drop_for_rate_limiting,omitempty"` - // Indicates whether this particular request should be dropped by the client - // for load balancing. - DropForLoadBalancing bool `protobuf:"varint,5,opt,name=drop_for_load_balancing,json=dropForLoadBalancing" json:"drop_for_load_balancing,omitempty"` -} - -func (m *Server) Reset() { *m = Server{} } -func (m *Server) String() string { return proto.CompactTextString(m) } -func (*Server) ProtoMessage() {} -func (*Server) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } - -func (m *Server) GetIpAddress() []byte { - if m != nil { - return m.IpAddress - } - return nil -} - -func (m *Server) GetPort() int32 { - if m != nil { - return m.Port - } - return 0 -} - -func (m *Server) GetLoadBalanceToken() string { - if m != nil { - return m.LoadBalanceToken - } - return "" -} - -func (m *Server) GetDropForRateLimiting() bool { - if m != nil { - return m.DropForRateLimiting - } - return false -} - -func (m *Server) GetDropForLoadBalancing() bool { - if m != nil { - return m.DropForLoadBalancing - } - return false -} - -func init() { - proto.RegisterType((*Duration)(nil), "grpc.lb.v1.Duration") - proto.RegisterType((*Timestamp)(nil), "grpc.lb.v1.Timestamp") - proto.RegisterType((*LoadBalanceRequest)(nil), "grpc.lb.v1.LoadBalanceRequest") - proto.RegisterType((*InitialLoadBalanceRequest)(nil), "grpc.lb.v1.InitialLoadBalanceRequest") - proto.RegisterType((*ClientStats)(nil), "grpc.lb.v1.ClientStats") - proto.RegisterType((*LoadBalanceResponse)(nil), "grpc.lb.v1.LoadBalanceResponse") - proto.RegisterType((*InitialLoadBalanceResponse)(nil), "grpc.lb.v1.InitialLoadBalanceResponse") - proto.RegisterType((*ServerList)(nil), "grpc.lb.v1.ServerList") - proto.RegisterType((*Server)(nil), "grpc.lb.v1.Server") -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// Client API for LoadBalancer service - -type LoadBalancerClient interface { - // Bidirectional rpc to get a list of servers. - BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) -} - -type loadBalancerClient struct { - cc *grpc.ClientConn -} - -func NewLoadBalancerClient(cc *grpc.ClientConn) LoadBalancerClient { - return &loadBalancerClient{cc} -} - -func (c *loadBalancerClient) BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) { - stream, err := grpc.NewClientStream(ctx, &_LoadBalancer_serviceDesc.Streams[0], c.cc, "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...) - if err != nil { - return nil, err - } - x := &loadBalancerBalanceLoadClient{stream} - return x, nil -} - -type LoadBalancer_BalanceLoadClient interface { - Send(*LoadBalanceRequest) error - Recv() (*LoadBalanceResponse, error) - grpc.ClientStream -} - -type loadBalancerBalanceLoadClient struct { - grpc.ClientStream -} - -func (x *loadBalancerBalanceLoadClient) Send(m *LoadBalanceRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *loadBalancerBalanceLoadClient) Recv() (*LoadBalanceResponse, error) { - m := new(LoadBalanceResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// Server API for LoadBalancer service - -type LoadBalancerServer interface { - // Bidirectional rpc to get a list of servers. - BalanceLoad(LoadBalancer_BalanceLoadServer) error -} - -func RegisterLoadBalancerServer(s *grpc.Server, srv LoadBalancerServer) { - s.RegisterService(&_LoadBalancer_serviceDesc, srv) -} - -func _LoadBalancer_BalanceLoad_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(LoadBalancerServer).BalanceLoad(&loadBalancerBalanceLoadServer{stream}) -} - -type LoadBalancer_BalanceLoadServer interface { - Send(*LoadBalanceResponse) error - Recv() (*LoadBalanceRequest, error) - grpc.ServerStream -} - -type loadBalancerBalanceLoadServer struct { - grpc.ServerStream -} - -func (x *loadBalancerBalanceLoadServer) Send(m *LoadBalanceResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *loadBalancerBalanceLoadServer) Recv() (*LoadBalanceRequest, error) { - m := new(LoadBalanceRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -var _LoadBalancer_serviceDesc = grpc.ServiceDesc{ - ServiceName: "grpc.lb.v1.LoadBalancer", - HandlerType: (*LoadBalancerServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "BalanceLoad", - Handler: _LoadBalancer_BalanceLoad_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "grpc_lb_v1/grpclb.proto", -} - -func init() { proto.RegisterFile("grpc_lb_v1/grpclb.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 740 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcd, 0x4e, 0x1b, 0x3b, - 0x14, 0x66, 0x6e, 0xf8, 0xcb, 0x09, 0xba, 0x70, 0x4d, 0x2e, 0x04, 0x2e, 0xdc, 0xd2, 0x48, 0xa5, - 0x51, 0x45, 0x43, 0x09, 0xed, 0xa2, 0x3f, 0x9b, 0x02, 0x45, 0x41, 0x65, 0x51, 0x39, 0x54, 0x5d, - 0x55, 0x96, 0x93, 0x31, 0x60, 0x31, 0xb1, 0xa7, 0xb6, 0x13, 0xda, 0x65, 0x97, 0x7d, 0x94, 0x3e, - 0x46, 0xd5, 0x67, 0xe8, 0xfb, 0x54, 0xb6, 0x67, 0x32, 0x03, 0xf9, 0x41, 0xdd, 0xd9, 0xc7, 0xdf, - 0xf9, 0xce, 0xe7, 0x33, 0xfe, 0xce, 0xc0, 0xea, 0x85, 0x8a, 0x3b, 0x24, 0x6a, 0x93, 0xfe, 0xde, - 0xae, 0x5d, 0x46, 0xed, 0x7a, 0xac, 0xa4, 0x91, 0x08, 0xec, 0xae, 0x1e, 0xb5, 0xeb, 0xfd, 0xbd, - 0xea, 0x0b, 0x98, 0x3f, 0xea, 0x29, 0x6a, 0xb8, 0x14, 0xa8, 0x02, 0x73, 0x9a, 0x75, 0xa4, 0x08, - 0x75, 0x25, 0xd8, 0x0a, 0x6a, 0x05, 0x9c, 0x6e, 0x51, 0x19, 0x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9, 0x8a, 0xf3, 0xb8, - 0x1c, 0x8e, 0xb0, 0x5d, 0xa3, 0x0d, 0x0b, 0xb9, 0xef, 0xaf, 0x10, 0x86, 0x52, 0xb2, 0xb6, 0x61, - 0xf4, 0x7f, 0xbe, 0x41, 0xc3, 0xc3, 0x72, 0xfd, 0xde, 0xd8, 0x73, 0xff, 0x90, 0x6a, 0xc1, 0x93, - 0xa0, 0x3d, 0xeb, 0x7e, 0x5f, 0xfb, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xab, 0xe2, 0x32, 0x4b, - 0xd9, 0x06, 0x00, 0x00, -} diff --git a/grpclb/messages_only/grpc_lb_v1/grpclb.pb.go b/grpclb/grpc_lb_v1/messages/messages.pb.go similarity index 82% rename from grpclb/messages_only/grpc_lb_v1/grpclb.pb.go rename to grpclb/grpc_lb_v1/messages/messages.pb.go index cc62319717d2..94a58321a9d5 100644 --- a/grpclb/messages_only/grpc_lb_v1/grpclb.pb.go +++ b/grpclb/grpc_lb_v1/messages/messages.pb.go @@ -1,11 +1,11 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc_lb_v1/grpclb.proto +// source: grpc_lb_v1/messages/messages.proto /* Package grpc_lb_v1 is a generated protocol buffer package. It is generated from these files: - grpc_lb_v1/grpclb.proto + grpc_lb_v1/messages/messages.proto It has these top-level messages: Duration @@ -575,55 +575,53 @@ func init() { proto.RegisterType((*Server)(nil), "grpc.lb.v1.Server") } -func init() { proto.RegisterFile("grpc_lb_v1/grpclb.proto", fileDescriptor0) } +func init() { proto.RegisterFile("grpc_lb_v1/messages/messages.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 740 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcd, 0x4e, 0x1b, 0x3b, - 0x14, 0x66, 0x6e, 0xf8, 0xcb, 0x09, 0xba, 0x70, 0x4d, 0x2e, 0x04, 0x2e, 0xdc, 0xd2, 0x48, 0xa5, - 0x51, 0x45, 0x43, 0x09, 0xed, 0xa2, 0x3f, 0x9b, 0x02, 0x45, 0x41, 0x65, 0x51, 0x39, 0x54, 0x5d, - 0x55, 0x96, 0x93, 0x31, 0x60, 0x31, 0xb1, 0xa7, 0xb6, 0x13, 0xda, 0x65, 0x97, 0x7d, 0x94, 0x3e, - 0x46, 0xd5, 0x67, 0xe8, 0xfb, 0x54, 0xb6, 0x67, 0x32, 0x03, 0xf9, 0x41, 0xdd, 0xd9, 0xc7, 0xdf, - 0xf9, 0xce, 0xe7, 0x33, 0xfe, 0xce, 0xc0, 0xea, 0x85, 0x8a, 0x3b, 0x24, 0x6a, 0x93, 0xfe, 0xde, - 0xae, 0x5d, 0x46, 0xed, 0x7a, 0xac, 0xa4, 0x91, 0x08, 0xec, 0xae, 0x1e, 0xb5, 0xeb, 0xfd, 0xbd, - 0xea, 0x0b, 0x98, 0x3f, 0xea, 0x29, 0x6a, 0xb8, 0x14, 0xa8, 0x02, 0x73, 0x9a, 0x75, 0xa4, 0x08, - 0x75, 0x25, 0xd8, 0x0a, 0x6a, 0x05, 0x9c, 0x6e, 0x51, 0x19, 0x66, 0x04, 0x15, 0x52, 0x57, 0xfe, - 0xda, 0x0a, 0x6a, 0x33, 0xd8, 0x6f, 0xaa, 0x2f, 0xa1, 0x78, 0xc6, 0xbb, 0x4c, 0x1b, 0xda, 0x8d, - 0xff, 0x38, 0xf9, 0x47, 0x00, 0xe8, 0x54, 0xd2, 0xf0, 0x80, 0x46, 0x54, 0x74, 0x18, 0x66, 0x9f, - 0x7a, 0x4c, 0x1b, 0xf4, 0x0e, 0x16, 0xb9, 0xe0, 0x86, 0xd3, 0x88, 0x28, 0x1f, 0x72, 0x74, 0xa5, - 0xc6, 0x83, 0x7a, 0xa6, 0xba, 0x7e, 0xe2, 0x21, 0xc3, 0xf9, 0xcd, 0x29, 0xfc, 0x77, 0x92, 0x9f, - 0x32, 0xbe, 0x82, 0x85,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9c, - 0x7b, 0xb1, 0xcb, 0x3b, 0x49, 0xd2, 0xaa, 0x5f, 0x03, 0x80, 0xec, 0x9a, 0x68, 0xc7, 0x4e, 0x2c, - 0xbb, 0xb3, 0x13, 0xab, 0x50, 0x2b, 0x35, 0xd0, 0x70, 0x3f, 0x70, 0x0a, 0x41, 0x6f, 0x60, 0x99, - 0x7d, 0x8e, 0xb9, 0xaf, 0x92, 0x49, 0x29, 0x4c, 0x90, 0x82, 0xb2, 0x84, 0x81, 0x86, 0x5f, 0x01, - 0xcc, 0x7a, 0x6a, 0xb4, 0x09, 0xc0, 0x63, 0x42, 0xc3, 0x50, 0x31, 0xed, 0x87, 0xe6, 0x02, 0x2e, - 0xf2, 0xf8, 0xb5, 0x0f, 0xd8, 0xf9, 0x61, 0xd5, 0x27, 0x53, 0xd3, 0xad, 0xad, 0x9d, 0x6f, 0x7c, - 0x0b, 0x23, 0xaf, 0x98, 0x70, 0x1a, 0x8a, 0x78, 0x29, 0xd7, 0xca, 0x33, 0x1b, 0x47, 0xfb, 0xb0, - 0x32, 0xc1, 0xb6, 0xf3, 0x78, 0x39, 0x1c, 0x61, 0xd1, 0x67, 0xb0, 0x3a, 0xc9, 0x8a, 0xf3, 0xb8, - 0x1c, 0x8e, 0xb0, 0x5d, 0xa3, 0x0d, 0x0b, 0xb9, 0xef, 0xaf, 0x10, 0x86, 0x52, 0xb2, 0xb6, 0x61, - 0xf4, 0x7f, 0xbe, 0x41, 0xc3, 0xc3, 0x72, 0xfd, 0xde, 0xd8, 0x73, 0xff, 0x90, 0x6a, 0xc1, 0x93, - 0xa0, 0x3d, 0xeb, 0x7e, 0x5f, 0xfb, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xab, 0xe2, 0x32, 0x4b, - 0xd9, 0x06, 0x00, 0x00, + // 715 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xdd, 0x4e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 0x72, 0x8b, 0x67, 0x29, 0x9c, + 0x70, 0xd8, 0x7d, 0xb0, 0x40, 0xa1, 0xdd, 0x49, 0x85, 0x19, 0x57, 0xa1, 0x31, 0xa1, 0x42, 0xde, + 0xfb, 0xa4, 0xc4, 0x07, 0x78, 0x7c, 0x5f, 0x89, 0xf4, 0x19, 0x5c, 0x70, 0x11, 0x61, 0xc8, 0xac, + 0x62, 0x06, 0x65, 0x58, 0x9b, 0x75, 0x05, 0xb6, 0xc7, 0x15, 0xf0, 0x9f, 0xea, 0xc4, 0xe1, 0xcf, + 0x55, 0x1b, 0x65, 0x48, 0x5a, 0xf0, 0xef, 0x18, 0xfa, 0x2b, 0xa9, 0xae, 0x25, 0xd3, 0xd8, 0x45, + 0x31, 0xc4, 0xb0, 0x36, 0xe7, 0x28, 0x37, 0x6f, 0x53, 0xbe, 0x49, 0x50, 0x34, 0x05, 0xd5, 0x7f, + 0x04, 0xb0, 0x7c, 0xe3, 0xd9, 0x98, 0x58, 0x49, 0x83, 0xa4, 0x0d, 0x4b, 0xb9, 0x03, 0x7c, 0x2c, + 0x7d, 0x1a, 0xdb, 0x0f, 0x59, 0xc0, 0xa3, 0x5b, 0x53, 0x74, 0x71, 0xe4, 0x81, 0x94, 0xf4, 0x19, + 0x54, 0x0c, 0xea, 0x21, 0x6a, 0x16, 0x09, 0x63, 0x53, 0x0f, 0xac, 0x14, 0xf9, 0xda, 0xee, 0xf8, + 0x4c, 0x38, 0x0f, 0x81, 0x19, 0xed, 0x0e, 0x37, 0x60, 0xfd, 0x96, 0x03, 0x3c, 0xa7, 0xb7, 0xc0, + 0xb7, 0x00, 0xd6, 0xef, 0x97, 0x42, 0x9e, 0xc0, 0x4a, 0x31, 0x59, 0xb3, 0x10, 0x23, 0xec, 0x71, + 0x9b, 0xd9, 0xa2, 0x1a, 0xe5, 0x49, 0xfa, 0x38, 0x3d, 0x23, 0xef, 0x60, 0xa3, 0x68, 0x59, 0xa6, + 0x31, 0x56, 0xda, 0x32, 0x21, 0x2d, 0xea, 0x21, 0x8f, 0x52, 0xf9, 0xd5, 0xa2, 0xfc, 0x6c, 0x88, + 0xd1, 0xb5, 0x82, 0x7b, 0xa9, 0xcb, 0x3b, 0x4d, 0xd3, 0xea, 0x5f, 0x02, 0x80, 0xfc, 0x9a, 0x64, + 0x27, 0x99, 0x58, 0xc9, 0x2e, 0x99, 0x58, 0xa5, 0x46, 0x65, 0x9f, 0xdc, 0xed, 0x07, 0xcd, 0x20, + 0xe4, 0x35, 0x2c, 0xe3, 0xa7, 0x58, 0xf8, 0x2a, 0xb9, 0x94, 0xd2, 0x04, 0x29, 0x24, 0x4f, 0x18, + 0x69, 0xf8, 0x19, 0xc0, 0xac, 0xa7, 0x26, 0x9b, 0x00, 0x22, 0x66, 0x3c, 0x0c, 0x35, 0x1a, 0x3f, + 0x34, 0x17, 0x68, 0x59, 0xc4, 0xaf, 0x7c, 0x20, 0x99, 0x1f, 0x89, 0xfa, 0x74, 0x6a, 0xba, 0x75, + 0x62, 0xe7, 0x1b, 0xdf, 0xc2, 0xaa, 0x2b, 0x94, 0x4e, 0x43, 0x99, 0x2e, 0x15, 0x5a, 0x79, 0x9e, + 0xc4, 0xc9, 0x01, 0xac, 0x4c, 0xb0, 0xed, 0x3c, 0x5d, 0x0e, 0xc7, 0x58, 0xf4, 0x29, 0xac, 0x4e, + 0xb2, 0xe2, 0x3c, 0xad, 0x86, 0x63, 0x6c, 0xd7, 0x99, 0x75, 0xbf, 0x96, 0x83, 0x5f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xcd, 0x4e, 0x4b, 0xde, 0x80, 0x06, 0x00, 0x00, } diff --git a/grpclb/grpc_lb_v1/grpclb.proto b/grpclb/grpc_lb_v1/messages/messages.proto similarity index 97% rename from grpclb/grpc_lb_v1/grpclb.proto rename to grpclb/grpc_lb_v1/messages/messages.proto index b13b3438cf27..10fe344e007a 100644 --- a/grpclb/grpc_lb_v1/grpclb.proto +++ b/grpclb/grpc_lb_v1/messages/messages.proto @@ -44,12 +44,6 @@ message Timestamp { int32 nanos = 2; } -service LoadBalancer { - // Bidirectional rpc to get a list of servers. - rpc BalanceLoad(stream LoadBalanceRequest) - returns (stream LoadBalanceResponse); -} - message LoadBalanceRequest { oneof load_balance_request_type { // This message should be sent on the first request to the load balancer. diff --git a/grpclb/grpc_lb_v1/service/service.pb.go b/grpclb/grpc_lb_v1/service/service.pb.go new file mode 100644 index 000000000000..b78161109289 --- /dev/null +++ b/grpclb/grpc_lb_v1/service/service.pb.go @@ -0,0 +1,154 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: grpc_lb_v1/service/service.proto + +/* +Package grpc_lb_v1 is a generated protocol buffer package. + +It is generated from these files: + grpc_lb_v1/service/service.proto + +It has these top-level messages: +*/ +package grpc_lb_v1 + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import grpc_lb_v11 "google.golang.org/grpc/grpclb/grpc_lb_v1/messages" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for LoadBalancer service + +type LoadBalancerClient interface { + // Bidirectional rpc to get a list of servers. + BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) +} + +type loadBalancerClient struct { + cc *grpc.ClientConn +} + +func NewLoadBalancerClient(cc *grpc.ClientConn) LoadBalancerClient { + return &loadBalancerClient{cc} +} + +func (c *loadBalancerClient) BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) { + stream, err := grpc.NewClientStream(ctx, &_LoadBalancer_serviceDesc.Streams[0], c.cc, "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...) + if err != nil { + return nil, err + } + x := &loadBalancerBalanceLoadClient{stream} + return x, nil +} + +type LoadBalancer_BalanceLoadClient interface { + Send(*grpc_lb_v11.LoadBalanceRequest) error + Recv() (*grpc_lb_v11.LoadBalanceResponse, error) + grpc.ClientStream +} + +type loadBalancerBalanceLoadClient struct { + grpc.ClientStream +} + +func (x *loadBalancerBalanceLoadClient) Send(m *grpc_lb_v11.LoadBalanceRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *loadBalancerBalanceLoadClient) Recv() (*grpc_lb_v11.LoadBalanceResponse, error) { + m := new(grpc_lb_v11.LoadBalanceResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Server API for LoadBalancer service + +type LoadBalancerServer interface { + // Bidirectional rpc to get a list of servers. + BalanceLoad(LoadBalancer_BalanceLoadServer) error +} + +func RegisterLoadBalancerServer(s *grpc.Server, srv LoadBalancerServer) { + s.RegisterService(&_LoadBalancer_serviceDesc, srv) +} + +func _LoadBalancer_BalanceLoad_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(LoadBalancerServer).BalanceLoad(&loadBalancerBalanceLoadServer{stream}) +} + +type LoadBalancer_BalanceLoadServer interface { + Send(*grpc_lb_v11.LoadBalanceResponse) error + Recv() (*grpc_lb_v11.LoadBalanceRequest, error) + grpc.ServerStream +} + +type loadBalancerBalanceLoadServer struct { + grpc.ServerStream +} + +func (x *loadBalancerBalanceLoadServer) Send(m *grpc_lb_v11.LoadBalanceResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *loadBalancerBalanceLoadServer) Recv() (*grpc_lb_v11.LoadBalanceRequest, error) { + m := new(grpc_lb_v11.LoadBalanceRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _LoadBalancer_serviceDesc = grpc.ServiceDesc{ + ServiceName: "grpc.lb.v1.LoadBalancer", + HandlerType: (*LoadBalancerServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "BalanceLoad", + Handler: _LoadBalancer_BalanceLoad_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "grpc_lb_v1/service/service.proto", +} + +func init() { proto.RegisterFile("grpc_lb_v1/service/service.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 136 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x2f, 0x2a, 0x48, + 0x8e, 0xcf, 0x49, 0x8a, 0x2f, 0x33, 0xd4, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0x85, 0xd1, + 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x5c, 0x20, 0x15, 0x7a, 0x39, 0x49, 0x7a, 0x65, 0x86, + 0x52, 0x4a, 0x48, 0xaa, 0x73, 0x53, 0x8b, 0x8b, 0x13, 0xd3, 0x53, 0x8b, 0xe1, 0x0c, 0x88, 0x7a, + 0xa3, 0x24, 0x2e, 0x1e, 0x9f, 0xfc, 0xc4, 0x14, 0xa7, 0xc4, 0x9c, 0xc4, 0xbc, 0xe4, 0xd4, 0x22, + 0xa1, 0x20, 0x2e, 0x6e, 0x28, 0x1b, 0x24, 0x2c, 0x24, 0xa7, 0x87, 0x30, 0x4f, 0x0f, 0x49, 0x61, + 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x94, 0x3c, 0x4e, 0xf9, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, + 0x54, 0x0d, 0x46, 0x03, 0xc6, 0x24, 0x36, 0xb0, 0x55, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x55, 0x79, 0x69, 0x22, 0xbe, 0x00, 0x00, 0x00, +} diff --git a/grpclb/grpc_lb_v1/service/service.proto b/grpclb/grpc_lb_v1/service/service.proto new file mode 100644 index 000000000000..7b09cd73be4b --- /dev/null +++ b/grpclb/grpc_lb_v1/service/service.proto @@ -0,0 +1,25 @@ +// Copyright 2016 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package grpc.lb.v1; + +import "grpc_lb_v1/messages/messages.proto"; + +service LoadBalancer { + // Bidirectional rpc to get a list of servers. + rpc BalanceLoad(stream LoadBalanceRequest) + returns (stream LoadBalanceResponse); +} diff --git a/grpclb/grpclb_test.go b/grpclb/grpclb_test.go index c5db15a8bdc4..89536e249506 100644 --- a/grpclb/grpclb_test.go +++ b/grpclb/grpclb_test.go @@ -16,11 +16,11 @@ * */ -//go:generate protoc --go_out=:messages_only grpc_lb_v1/grpclb.proto -//go:generate protoc --go_out=plugins=grpc:. grpc_lb_v1/grpclb.proto +//go:generate protoc --go_out=plugins=:. grpc_lb_v1/messages/messages.proto +//go:generate protoc --go_out=Mgrpc_lb_v1/messages/messages.proto=google.golang.org/grpc/grpclb/grpc_lb_v1/messages,plugins=grpc:. grpc_lb_v1/service/service.proto -// Package grpclb is currently used only for grpclb testing. -package grpclb +// Package grpclb_test is currently used only for grpclb testing. +package grpclb_test import ( "errors" @@ -37,7 +37,8 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" - lbpb "google.golang.org/grpc/grpclb/grpc_lb_v1" + lbmpb "google.golang.org/grpc/grpclb/grpc_lb_v1/messages" + lbspb "google.golang.org/grpc/grpclb/grpc_lb_v1/service" "google.golang.org/grpc/metadata" "google.golang.org/grpc/naming" testpb "google.golang.org/grpc/test/grpc_testing" @@ -184,15 +185,15 @@ func fakeNameDialer(addr string, timeout time.Duration) (net.Conn, error) { } type remoteBalancer struct { - sls []*lbpb.ServerList + sls []*lbmpb.ServerList intervals []time.Duration statsDura time.Duration done chan struct{} mu sync.Mutex - stats lbpb.ClientStats + stats lbmpb.ClientStats } -func newRemoteBalancer(sls []*lbpb.ServerList, intervals []time.Duration) *remoteBalancer { +func newRemoteBalancer(sls []*lbmpb.ServerList, intervals []time.Duration) *remoteBalancer { return &remoteBalancer{ sls: sls, intervals: intervals, @@ -204,7 +205,7 @@ func (b *remoteBalancer) stop() { close(b.done) } -func (b *remoteBalancer) BalanceLoad(stream lbpb.LoadBalancer_BalanceLoadServer) error { +func (b *remoteBalancer) BalanceLoad(stream lbspb.LoadBalancer_BalanceLoadServer) error { req, err := stream.Recv() if err != nil { return err @@ -213,10 +214,10 @@ func (b *remoteBalancer) BalanceLoad(stream lbpb.LoadBalancer_BalanceLoadServer) if initReq.Name != besn { return grpc.Errorf(codes.InvalidArgument, "invalid service name: %v", initReq.Name) } - resp := &lbpb.LoadBalanceResponse{ - LoadBalanceResponseType: &lbpb.LoadBalanceResponse_InitialResponse{ - InitialResponse: &lbpb.InitialLoadBalanceResponse{ - ClientStatsReportInterval: &lbpb.Duration{ + resp := &lbmpb.LoadBalanceResponse{ + LoadBalanceResponseType: &lbmpb.LoadBalanceResponse_InitialResponse{ + InitialResponse: &lbmpb.InitialLoadBalanceResponse{ + ClientStatsReportInterval: &lbmpb.Duration{ Seconds: int64(b.statsDura.Seconds()), Nanos: int32(b.statsDura.Nanoseconds() - int64(b.statsDura.Seconds())*1e9), }, @@ -229,7 +230,7 @@ func (b *remoteBalancer) BalanceLoad(stream lbpb.LoadBalancer_BalanceLoadServer) go func() { for { var ( - req *lbpb.LoadBalanceRequest + req *lbmpb.LoadBalanceRequest err error ) if req, err = stream.Recv(); err != nil { @@ -247,8 +248,8 @@ func (b *remoteBalancer) BalanceLoad(stream lbpb.LoadBalancer_BalanceLoadServer) }() for k, v := range b.sls { time.Sleep(b.intervals[k]) - resp = &lbpb.LoadBalanceResponse{ - LoadBalanceResponseType: &lbpb.LoadBalanceResponse_ServerList{ + resp = &lbmpb.LoadBalanceResponse{ + LoadBalanceResponseType: &lbmpb.LoadBalanceResponse_ServerList{ ServerList: v, }, } @@ -350,7 +351,7 @@ func newLoadBalancer(numberOfBackends int) (tss *testServers, cleanup func(), er return } ls = newRemoteBalancer(nil, nil) - lbpb.RegisterLoadBalancerServer(lb, ls) + lbspb.RegisterLoadBalancerServer(lb, ls) go func() { lb.Serve(lbLis) }() @@ -379,17 +380,17 @@ func TestGRPCLB(t *testing.T) { } defer cleanup() - be := &lbpb.Server{ + be := &lbmpb.Server{ IpAddress: tss.beIPs[0], Port: int32(tss.bePorts[0]), LoadBalanceToken: lbToken, } - var bes []*lbpb.Server + var bes []*lbmpb.Server bes = append(bes, be) - sl := &lbpb.ServerList{ + sl := &lbmpb.ServerList{ Servers: bes, } - tss.ls.sls = []*lbpb.ServerList{sl} + tss.ls.sls = []*lbmpb.ServerList{sl} tss.ls.intervals = []time.Duration{0} creds := serverNameCheckCreds{ expected: besn, @@ -415,8 +416,8 @@ func TestDropRequest(t *testing.T) { t.Fatalf("failed to create new load balancer: %v", err) } defer cleanup() - tss.ls.sls = []*lbpb.ServerList{{ - Servers: []*lbpb.Server{{ + tss.ls.sls = []*lbmpb.ServerList{{ + Servers: []*lbmpb.Server{{ IpAddress: tss.beIPs[0], Port: int32(tss.bePorts[0]), LoadBalanceToken: lbToken, @@ -467,18 +468,18 @@ func TestDropRequestFailedNonFailFast(t *testing.T) { t.Fatalf("failed to create new load balancer: %v", err) } defer cleanup() - be := &lbpb.Server{ + be := &lbmpb.Server{ IpAddress: tss.beIPs[0], Port: int32(tss.bePorts[0]), LoadBalanceToken: lbToken, DropForLoadBalancing: true, } - var bes []*lbpb.Server + var bes []*lbmpb.Server bes = append(bes, be) - sl := &lbpb.ServerList{ + sl := &lbmpb.ServerList{ Servers: bes, } - tss.ls.sls = []*lbpb.ServerList{sl} + tss.ls.sls = []*lbmpb.ServerList{sl} tss.ls.intervals = []time.Duration{0} creds := serverNameCheckCreds{ expected: besn, @@ -506,24 +507,24 @@ func TestServerExpiration(t *testing.T) { t.Fatalf("failed to create new load balancer: %v", err) } defer cleanup() - be := &lbpb.Server{ + be := &lbmpb.Server{ IpAddress: tss.beIPs[0], Port: int32(tss.bePorts[0]), LoadBalanceToken: lbToken, } - var bes []*lbpb.Server + var bes []*lbmpb.Server bes = append(bes, be) - exp := &lbpb.Duration{ + exp := &lbmpb.Duration{ Seconds: 0, Nanos: 100000000, // 100ms } - var sls []*lbpb.ServerList - sl := &lbpb.ServerList{ + var sls []*lbmpb.ServerList + sl := &lbmpb.ServerList{ Servers: bes, ExpirationInterval: exp, } sls = append(sls, sl) - sl = &lbpb.ServerList{ + sl = &lbmpb.ServerList{ Servers: bes, } sls = append(sls, sl) @@ -573,17 +574,17 @@ func TestBalancerDisconnects(t *testing.T) { } defer cleanup() - be := &lbpb.Server{ + be := &lbmpb.Server{ IpAddress: tss.beIPs[0], Port: int32(tss.bePorts[0]), LoadBalanceToken: lbToken, } - var bes []*lbpb.Server + var bes []*lbmpb.Server bes = append(bes, be) - sl := &lbpb.ServerList{ + sl := &lbmpb.ServerList{ Servers: bes, } - tss.ls.sls = []*lbpb.ServerList{sl} + tss.ls.sls = []*lbmpb.ServerList{sl} tss.ls.intervals = []time.Duration{0} lbAddrs = append(lbAddrs, tss.lbAddr) @@ -664,21 +665,21 @@ func (failPreRPCCred) RequireTransportSecurity() bool { return false } -func checkStats(stats *lbpb.ClientStats, expected *lbpb.ClientStats) error { +func checkStats(stats *lbmpb.ClientStats, expected *lbmpb.ClientStats) error { if !proto.Equal(stats, expected) { return fmt.Errorf("stats not equal: got %+v, want %+v", stats, expected) } return nil } -func runAndGetStats(t *testing.T, dropForLoadBalancing, dropForRateLimiting bool, runRPCs func(*grpc.ClientConn)) lbpb.ClientStats { +func runAndGetStats(t *testing.T, dropForLoadBalancing, dropForRateLimiting bool, runRPCs func(*grpc.ClientConn)) lbmpb.ClientStats { tss, cleanup, err := newLoadBalancer(3) if err != nil { t.Fatalf("failed to create new load balancer: %v", err) } defer cleanup() - tss.ls.sls = []*lbpb.ServerList{{ - Servers: []*lbpb.Server{{ + tss.ls.sls = []*lbmpb.ServerList{{ + Servers: []*lbmpb.Server{{ IpAddress: tss.beIPs[2], Port: int32(tss.bePorts[2]), LoadBalanceToken: lbToken, @@ -723,7 +724,7 @@ func TestGRPCLBStatsUnarySuccess(t *testing.T) { } }) - if err := checkStats(&stats, &lbpb.ClientStats{ + if err := checkStats(&stats, &lbmpb.ClientStats{ NumCallsStarted: int64(countRPC), NumCallsFinished: int64(countRPC), NumCallsFinishedKnownReceived: int64(countRPC), @@ -749,7 +750,7 @@ func TestGRPCLBStatsUnaryDropLoadBalancing(t *testing.T) { } }) - if err := checkStats(&stats, &lbpb.ClientStats{ + if err := checkStats(&stats, &lbmpb.ClientStats{ NumCallsStarted: int64(countRPC + c), NumCallsFinished: int64(countRPC + c), NumCallsFinishedWithDropForLoadBalancing: int64(countRPC + 1), @@ -776,7 +777,7 @@ func TestGRPCLBStatsUnaryDropRateLimiting(t *testing.T) { } }) - if err := checkStats(&stats, &lbpb.ClientStats{ + if err := checkStats(&stats, &lbmpb.ClientStats{ NumCallsStarted: int64(countRPC + c), NumCallsFinished: int64(countRPC + c), NumCallsFinishedWithDropForRateLimiting: int64(countRPC + 1), @@ -798,7 +799,7 @@ func TestGRPCLBStatsUnaryFailedToSend(t *testing.T) { } }) - if err := checkStats(&stats, &lbpb.ClientStats{ + if err := checkStats(&stats, &lbmpb.ClientStats{ NumCallsStarted: int64(countRPC), NumCallsFinished: int64(countRPC), NumCallsFinishedWithClientFailedToSend: int64(countRPC - 1), @@ -834,7 +835,7 @@ func TestGRPCLBStatsStreamingSuccess(t *testing.T) { } }) - if err := checkStats(&stats, &lbpb.ClientStats{ + if err := checkStats(&stats, &lbmpb.ClientStats{ NumCallsStarted: int64(countRPC), NumCallsFinished: int64(countRPC), NumCallsFinishedKnownReceived: int64(countRPC), @@ -860,7 +861,7 @@ func TestGRPCLBStatsStreamingDropLoadBalancing(t *testing.T) { } }) - if err := checkStats(&stats, &lbpb.ClientStats{ + if err := checkStats(&stats, &lbmpb.ClientStats{ NumCallsStarted: int64(countRPC + c), NumCallsFinished: int64(countRPC + c), NumCallsFinishedWithDropForLoadBalancing: int64(countRPC + 1), @@ -887,7 +888,7 @@ func TestGRPCLBStatsStreamingDropRateLimiting(t *testing.T) { } }) - if err := checkStats(&stats, &lbpb.ClientStats{ + if err := checkStats(&stats, &lbmpb.ClientStats{ NumCallsStarted: int64(countRPC + c), NumCallsFinished: int64(countRPC + c), NumCallsFinishedWithDropForRateLimiting: int64(countRPC + 1), @@ -915,7 +916,7 @@ func TestGRPCLBStatsStreamingFailedToSend(t *testing.T) { } }) - if err := checkStats(&stats, &lbpb.ClientStats{ + if err := checkStats(&stats, &lbmpb.ClientStats{ NumCallsStarted: int64(countRPC), NumCallsFinished: int64(countRPC), NumCallsFinishedWithClientFailedToSend: int64(countRPC - 1),