mirror of
https://github.com/zrepl/zrepl.git
synced 2025-08-17 02:11:03 +02:00
Update to protobuf v1.25 and grpc 1.35; bump CI to go1.12
From: github.com/golang/protobuf v1.3.2 google.golang.org/grpc v1.17.0 To: github.com/golang/protobuf v1.4.3 google.golang.org/grpc v1.35.0 google.golang.org/protobuf v1.25.0 About the two protobuf packages: https://developers.google.com/protocol-buffers/docs/reference/go/faq > Version v1.4.0 and higher of github.com/golang/protobuf wrap the new implementation and permit programs to adopt the new API incrementally. For example, the well-known types defined in github.com/golang/protobuf/ptypes are simply aliases of those defined in the newer module. Thus, google.golang.org/protobuf/types/known/emptypb and github.com/golang/protobuf/ptypes/empty may be used interchangeably. Notable Code Changes in zrepl: - generate protobufs now contain a mutex so we can't copy them by value anymore - grpc.WithDialer is deprecated => use grpc.WithContextDialer instead Go1.12 is now actually required by some of the dependencies.
This commit is contained in:
@ -7,7 +7,7 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/zrepl/zrepl/replication/logic/pdu"
|
||||
"github.com/zrepl/zrepl/rpc/dataconn/stream"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/zrepl/zrepl/logger"
|
||||
"github.com/zrepl/zrepl/replication/logic/pdu"
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
@ -28,12 +27,10 @@ import (
|
||||
|
||||
type Logger = logger.Logger
|
||||
|
||||
type GRPCDialFunction = func(string, time.Duration) (net.Conn, error)
|
||||
type GRPCDialFunction = func(context.Context, string) (net.Conn, error)
|
||||
|
||||
func NewDialer(logger Logger, connecter transport.Connecter) GRPCDialFunction {
|
||||
return func(s string, duration time.Duration) (conn net.Conn, e error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), duration)
|
||||
defer cancel()
|
||||
return func(ctx context.Context, s string) (conn net.Conn, e error) {
|
||||
nc, err := connecter.Connect(ctx)
|
||||
// TODO find better place (callback from gRPC?) where to log errors
|
||||
// we want the users to know, though
|
||||
|
@ -1,8 +1,8 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pdu";
|
||||
|
||||
package pdu;
|
||||
|
||||
|
||||
service Greeter {
|
||||
rpc Greet(GreetRequest) returns (GreetResponse) {}
|
||||
}
|
||||
@ -13,4 +13,4 @@ message GreetRequest {
|
||||
|
||||
message GreetResponse {
|
||||
string msg = 1;
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ func server() {
|
||||
|
||||
srv, serve := grpchelper.NewServer(authListener, clientIdentityKey, log, nil)
|
||||
|
||||
svc := &greeter{"hello "}
|
||||
svc := &greeter{prepend: "hello "}
|
||||
pdu.RegisterGreeterServer(srv, svc)
|
||||
|
||||
if err := serve(); err != nil {
|
||||
@ -103,6 +103,7 @@ func server() {
|
||||
}
|
||||
|
||||
type greeter struct {
|
||||
pdu.UnsafeGreeterServer
|
||||
prepend string
|
||||
}
|
||||
|
||||
|
@ -1,193 +1,214 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0
|
||||
// protoc v3.12.4
|
||||
// source: grpcauth.proto
|
||||
|
||||
package pdu
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
math "math"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 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
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
type GreetRequest struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (m *GreetRequest) Reset() { *m = GreetRequest{} }
|
||||
func (m *GreetRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*GreetRequest) ProtoMessage() {}
|
||||
func (x *GreetRequest) Reset() {
|
||||
*x = GreetRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpcauth_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GreetRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GreetRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GreetRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpcauth_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GreetRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GreetRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_1dfba7be0cf69353, []int{0}
|
||||
return file_grpcauth_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (m *GreetRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GreetRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GreetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GreetRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GreetRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GreetRequest.Merge(m, src)
|
||||
}
|
||||
func (m *GreetRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_GreetRequest.Size(m)
|
||||
}
|
||||
func (m *GreetRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GreetRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GreetRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *GreetRequest) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
func (x *GreetRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GreetResponse struct {
|
||||
Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||
}
|
||||
|
||||
func (m *GreetResponse) Reset() { *m = GreetResponse{} }
|
||||
func (m *GreetResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*GreetResponse) ProtoMessage() {}
|
||||
func (x *GreetResponse) Reset() {
|
||||
*x = GreetResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpcauth_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GreetResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GreetResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GreetResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpcauth_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GreetResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GreetResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_1dfba7be0cf69353, []int{1}
|
||||
return file_grpcauth_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (m *GreetResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GreetResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GreetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GreetResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GreetResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GreetResponse.Merge(m, src)
|
||||
}
|
||||
func (m *GreetResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_GreetResponse.Size(m)
|
||||
}
|
||||
func (m *GreetResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GreetResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GreetResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *GreetResponse) GetMsg() string {
|
||||
if m != nil {
|
||||
return m.Msg
|
||||
func (x *GreetResponse) GetMsg() string {
|
||||
if x != nil {
|
||||
return x.Msg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*GreetRequest)(nil), "pdu.GreetRequest")
|
||||
proto.RegisterType((*GreetResponse)(nil), "pdu.GreetResponse")
|
||||
var File_grpcauth_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_grpcauth_proto_rawDesc = []byte{
|
||||
0x0a, 0x0e, 0x67, 0x72, 0x70, 0x63, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x12, 0x03, 0x70, 0x64, 0x75, 0x22, 0x22, 0x0a, 0x0c, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x21, 0x0a, 0x0d, 0x47, 0x72, 0x65,
|
||||
0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73,
|
||||
0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0x3b, 0x0a, 0x07,
|
||||
0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x05, 0x47, 0x72, 0x65, 0x65, 0x74,
|
||||
0x12, 0x11, 0x2e, 0x70, 0x64, 0x75, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x64, 0x75, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x70,
|
||||
0x64, 0x75, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("grpcauth.proto", fileDescriptor_1dfba7be0cf69353) }
|
||||
var (
|
||||
file_grpcauth_proto_rawDescOnce sync.Once
|
||||
file_grpcauth_proto_rawDescData = file_grpcauth_proto_rawDesc
|
||||
)
|
||||
|
||||
var fileDescriptor_1dfba7be0cf69353 = []byte{
|
||||
// 137 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0x2f, 0x2a, 0x48,
|
||||
0x4e, 0x2c, 0x2d, 0xc9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2e, 0x48, 0x29, 0x55,
|
||||
0x52, 0xe2, 0xe2, 0x71, 0x2f, 0x4a, 0x4d, 0x2d, 0x09, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11,
|
||||
0x12, 0xe2, 0x62, 0xc9, 0x4b, 0xcc, 0x4d, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3,
|
||||
0x95, 0x14, 0xb9, 0x78, 0xa1, 0x6a, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0x04, 0xb8, 0x98,
|
||||
0x73, 0x8b, 0xd3, 0xa1, 0x6a, 0x40, 0x4c, 0x23, 0x6b, 0x2e, 0x76, 0xb0, 0x92, 0xd4, 0x22, 0x21,
|
||||
0x03, 0x2e, 0x56, 0x30, 0x53, 0x48, 0x50, 0xaf, 0x20, 0xa5, 0x54, 0x0f, 0xd9, 0x74, 0x29, 0x21,
|
||||
0x64, 0x21, 0x88, 0x61, 0x4a, 0x0c, 0x49, 0x6c, 0x60, 0xf7, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff,
|
||||
0xff, 0xa8, 0x53, 0x2f, 0x4c, 0xa1, 0x00, 0x00, 0x00,
|
||||
func file_grpcauth_proto_rawDescGZIP() []byte {
|
||||
file_grpcauth_proto_rawDescOnce.Do(func() {
|
||||
file_grpcauth_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpcauth_proto_rawDescData)
|
||||
})
|
||||
return file_grpcauth_proto_rawDescData
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// GreeterClient is the client API for Greeter service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type GreeterClient interface {
|
||||
Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error)
|
||||
var file_grpcauth_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_grpcauth_proto_goTypes = []interface{}{
|
||||
(*GreetRequest)(nil), // 0: pdu.GreetRequest
|
||||
(*GreetResponse)(nil), // 1: pdu.GreetResponse
|
||||
}
|
||||
var file_grpcauth_proto_depIdxs = []int32{
|
||||
0, // 0: pdu.Greeter.Greet:input_type -> pdu.GreetRequest
|
||||
1, // 1: pdu.Greeter.Greet:output_type -> pdu.GreetResponse
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
type greeterClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewGreeterClient(cc *grpc.ClientConn) GreeterClient {
|
||||
return &greeterClient{cc}
|
||||
}
|
||||
|
||||
func (c *greeterClient) Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error) {
|
||||
out := new(GreetResponse)
|
||||
err := c.cc.Invoke(ctx, "/pdu.Greeter/Greet", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
func init() { file_grpcauth_proto_init() }
|
||||
func file_grpcauth_proto_init() {
|
||||
if File_grpcauth_proto != nil {
|
||||
return
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GreeterServer is the server API for Greeter service.
|
||||
type GreeterServer interface {
|
||||
Greet(context.Context, *GreetRequest) (*GreetResponse, error)
|
||||
}
|
||||
|
||||
func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) {
|
||||
s.RegisterService(&_Greeter_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Greeter_Greet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GreetRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_grpcauth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GreetRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_grpcauth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GreetResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(GreeterServer).Greet(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pdu.Greeter/Greet",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(GreeterServer).Greet(ctx, req.(*GreetRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Greeter_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "pdu.Greeter",
|
||||
HandlerType: (*GreeterServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Greet",
|
||||
Handler: _Greeter_Greet_Handler,
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_grpcauth_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "grpcauth.proto",
|
||||
GoTypes: file_grpcauth_proto_goTypes,
|
||||
DependencyIndexes: file_grpcauth_proto_depIdxs,
|
||||
MessageInfos: file_grpcauth_proto_msgTypes,
|
||||
}.Build()
|
||||
File_grpcauth_proto = out.File
|
||||
file_grpcauth_proto_rawDesc = nil
|
||||
file_grpcauth_proto_goTypes = nil
|
||||
file_grpcauth_proto_depIdxs = nil
|
||||
}
|
||||
|
101
rpc/grpcclientidentity/example/pdu/grpcauth_grpc.pb.go
Normal file
101
rpc/grpcclientidentity/example/pdu/grpcauth_grpc.pb.go
Normal file
@ -0,0 +1,101 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
||||
package pdu
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// GreeterClient is the client API for Greeter 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.
|
||||
type GreeterClient interface {
|
||||
Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error)
|
||||
}
|
||||
|
||||
type greeterClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient {
|
||||
return &greeterClient{cc}
|
||||
}
|
||||
|
||||
func (c *greeterClient) Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error) {
|
||||
out := new(GreetResponse)
|
||||
err := c.cc.Invoke(ctx, "/pdu.Greeter/Greet", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GreeterServer is the server API for Greeter service.
|
||||
// All implementations must embed UnimplementedGreeterServer
|
||||
// for forward compatibility
|
||||
type GreeterServer interface {
|
||||
Greet(context.Context, *GreetRequest) (*GreetResponse, error)
|
||||
mustEmbedUnimplementedGreeterServer()
|
||||
}
|
||||
|
||||
// UnimplementedGreeterServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedGreeterServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedGreeterServer) Greet(context.Context, *GreetRequest) (*GreetResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Greet not implemented")
|
||||
}
|
||||
func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {}
|
||||
|
||||
// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to GreeterServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeGreeterServer interface {
|
||||
mustEmbedUnimplementedGreeterServer()
|
||||
}
|
||||
|
||||
func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) {
|
||||
s.RegisterService(&Greeter_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Greeter_Greet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GreetRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(GreeterServer).Greet(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pdu.Greeter/Greet",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(GreeterServer).Greet(ctx, req.(*GreetRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Greeter_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "pdu.Greeter",
|
||||
HandlerType: (*GreeterServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Greet",
|
||||
Handler: _Greeter_Greet_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "grpcauth.proto",
|
||||
}
|
@ -34,8 +34,10 @@ func ClientConn(cn transport.Connecter, log Logger) *grpc.ClientConn {
|
||||
Timeout: KeepalivePeerTimeout,
|
||||
PermitWithoutStream: true,
|
||||
})
|
||||
dialerOption := grpc.WithDialer(grpcclientidentity.NewDialer(log, cn))
|
||||
dialerOption := grpc.WithContextDialer(grpcclientidentity.NewDialer(log, cn))
|
||||
cred := grpc.WithTransportCredentials(grpcclientidentity.NewTransportCredentials(log))
|
||||
// we use context.Background without a timeout here because we don't set grpc.WithBlock
|
||||
// => docs: "In the non-blocking case, the ctx does not act against the connection. It only controls the setup steps."
|
||||
cc, err := grpc.DialContext(context.Background(), "doesn't matter done by dialer", dialerOption, cred, ka)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("cannot create gRPC client conn (non-blocking)")
|
||||
|
@ -172,14 +172,14 @@ func (c *Client) WaitForConnectivity(ctx context.Context) error {
|
||||
}
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ctrl, ctrlErr := c.controlClient.Ping(ctx, &req, grpc.FailFast(false))
|
||||
ctrl, ctrlErr := c.controlClient.Ping(ctx, &req, grpc.WaitForReady(true))
|
||||
checkRes(ctrl, ctrlErr, loggers.Control, &ctrlOk)
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for ctx.Err() == nil {
|
||||
data, dataErr := c.dataClient.ReqPing(ctx, &req)
|
||||
// dataClient uses transport.Connecter, which doesn't expose FailFast(false)
|
||||
// dataClient uses transport.Connecter, which doesn't expose WaitForReady(true)
|
||||
// => we need to mask dial timeouts
|
||||
if err, ok := dataErr.(interface{ Temporary() bool }); ok && err.Temporary() {
|
||||
// Rate-limit pings here in case Temporary() is a mis-classification
|
||||
|
Reference in New Issue
Block a user