rpc rewrite: control RPCs using gRPC + separate RPC for data transfer
transport/ssh: update go-netssh to new version
=> supports CloseWrite and Deadlines
=> build: require Go 1.11 (netssh requires it)
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
// Package grpcclientidentity makes the client identity
|
||||
// provided by github.com/zrepl/zrepl/daemon/transport/serve.{AuthenticatedListener,AuthConn}
|
||||
// available to gRPC service handlers.
|
||||
//
|
||||
// This goal is achieved through the combination of custom gRPC transport credentials and two interceptors
|
||||
// (i.e. middleware).
|
||||
//
|
||||
// For gRPC clients, the TransportCredentials + Dialer can be used to construct a gRPC client (grpc.ClientConn)
|
||||
// that uses a github.com/zrepl/zrepl/daemon/transport/connect.Connecter to connect to a server.
|
||||
//
|
||||
// The adaptors exposed by this package must be used together, and panic if they are not.
|
||||
// See package grpchelper for a more restrictive but safe example on how the adaptors should be composed.
|
||||
package grpcclientidentity
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/zrepl/zrepl/logger"
|
||||
"github.com/zrepl/zrepl/transport"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/peer"
|
||||
)
|
||||
|
||||
type Logger = logger.Logger
|
||||
|
||||
type GRPCDialFunction = func(string, time.Duration) (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()
|
||||
nc, err := connecter.Connect(ctx)
|
||||
// TODO find better place (callback from gRPC?) where to log errors
|
||||
// we want the users to know, though
|
||||
if err != nil {
|
||||
logger.WithError(err).Error("cannot connect")
|
||||
}
|
||||
return nc, err
|
||||
}
|
||||
}
|
||||
|
||||
type authConnAuthType struct {
|
||||
clientIdentity string
|
||||
}
|
||||
|
||||
func (authConnAuthType) AuthType() string {
|
||||
return "AuthConn"
|
||||
}
|
||||
|
||||
type connecterAuthType struct{}
|
||||
|
||||
func (connecterAuthType) AuthType() string {
|
||||
return "connecter"
|
||||
}
|
||||
|
||||
type transportCredentials struct {
|
||||
logger Logger
|
||||
}
|
||||
|
||||
// Use on both sides as ServerOption or ClientOption.
|
||||
func NewTransportCredentials(log Logger) credentials.TransportCredentials {
|
||||
if log == nil {
|
||||
log = logger.NewNullLogger()
|
||||
}
|
||||
return &transportCredentials{log}
|
||||
}
|
||||
|
||||
func (c *transportCredentials) ClientHandshake(ctx context.Context, s string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
|
||||
c.logger.WithField("url", s).WithField("connType", fmt.Sprintf("%T", rawConn)).Debug("ClientHandshake")
|
||||
// do nothing, client credential is only for WithInsecure warning to go away
|
||||
// the authentication is done by the connecter
|
||||
return rawConn, &connecterAuthType{}, nil
|
||||
}
|
||||
|
||||
func (c *transportCredentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
|
||||
c.logger.WithField("connType", fmt.Sprintf("%T", rawConn)).Debug("ServerHandshake")
|
||||
authConn, ok := rawConn.(*transport.AuthConn)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("NewTransportCredentials must be used with a listener that returns *transport.AuthConn, got %T", rawConn))
|
||||
}
|
||||
return rawConn, &authConnAuthType{authConn.ClientIdentity()}, nil
|
||||
}
|
||||
|
||||
func (*transportCredentials) Info() credentials.ProtocolInfo {
|
||||
return credentials.ProtocolInfo{} // TODO
|
||||
}
|
||||
|
||||
func (t *transportCredentials) Clone() credentials.TransportCredentials {
|
||||
var x = *t
|
||||
return &x
|
||||
}
|
||||
|
||||
func (*transportCredentials) OverrideServerName(string) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func NewInterceptors(logger Logger, clientIdentityKey interface{}) (unary grpc.UnaryServerInterceptor, stream grpc.StreamServerInterceptor) {
|
||||
unary = func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
logger.WithField("fullMethod", info.FullMethod).Debug("request")
|
||||
p, ok := peer.FromContext(ctx)
|
||||
if !ok {
|
||||
panic("peer.FromContext expected to return a peer in grpc.UnaryServerInterceptor")
|
||||
}
|
||||
logger.WithField("peer", fmt.Sprintf("%v", p)).Debug("peer")
|
||||
a, ok := p.AuthInfo.(*authConnAuthType)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("NewInterceptors must be used in combination with grpc.NewTransportCredentials, but got auth type %T", p.AuthInfo))
|
||||
}
|
||||
ctx = context.WithValue(ctx, clientIdentityKey, a.clientIdentity)
|
||||
return handler(ctx, req)
|
||||
}
|
||||
stream = nil
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package pdu;
|
||||
|
||||
|
||||
service Greeter {
|
||||
rpc Greet(GreetRequest) returns (GreetResponse) {}
|
||||
}
|
||||
|
||||
message GreetRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message GreetResponse {
|
||||
string msg = 1;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// This package demonstrates how the grpcclientidentity package can be used
|
||||
// to set up a gRPC greeter service.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/zrepl/zrepl/config"
|
||||
"github.com/zrepl/zrepl/logger"
|
||||
"github.com/zrepl/zrepl/rpc/grpcclientidentity/example/pdu"
|
||||
"github.com/zrepl/zrepl/rpc/grpcclientidentity/grpchelper"
|
||||
"github.com/zrepl/zrepl/transport/tcp"
|
||||
)
|
||||
|
||||
var args struct {
|
||||
mode string
|
||||
}
|
||||
|
||||
var log = logger.NewStderrDebugLogger()
|
||||
|
||||
func main() {
|
||||
flag.StringVar(&args.mode, "mode", "", "client|server")
|
||||
flag.Parse()
|
||||
|
||||
switch args.mode {
|
||||
case "client":
|
||||
client()
|
||||
case "server":
|
||||
server()
|
||||
default:
|
||||
log.Printf("unknown mode %q")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func onErr(err error, format string, args ...interface{}) {
|
||||
log.WithError(err).Error(fmt.Sprintf("%s: %s", fmt.Sprintf(format, args...), err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func client() {
|
||||
cn, err := tcp.TCPConnecterFromConfig(&config.TCPConnect{
|
||||
ConnectCommon: config.ConnectCommon{
|
||||
Type: "tcp",
|
||||
},
|
||||
Address: "127.0.0.1:8080",
|
||||
DialTimeout: 10 * time.Second,
|
||||
})
|
||||
if err != nil {
|
||||
onErr(err, "build connecter error")
|
||||
}
|
||||
|
||||
clientConn := grpchelper.ClientConn(cn, log)
|
||||
defer clientConn.Close()
|
||||
|
||||
// normal usage from here on
|
||||
|
||||
client := pdu.NewGreeterClient(clientConn)
|
||||
resp, err := client.Greet(context.Background(), &pdu.GreetRequest{Name: "somethingimadeup"})
|
||||
if err != nil {
|
||||
onErr(err, "RPC error")
|
||||
}
|
||||
|
||||
fmt.Printf("got response:\n\t%s\n", resp.GetMsg())
|
||||
}
|
||||
|
||||
const clientIdentityKey = "clientIdentity"
|
||||
|
||||
func server() {
|
||||
authListenerFactory, err := tcp.TCPListenerFactoryFromConfig(nil, &config.TCPServe{
|
||||
ServeCommon: config.ServeCommon{
|
||||
Type: "tcp",
|
||||
},
|
||||
Listen: "127.0.0.1:8080",
|
||||
Clients: map[string]string{
|
||||
"127.0.0.1": "localclient",
|
||||
"::1": "localclient",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
onErr(err, "cannot build listener factory")
|
||||
}
|
||||
|
||||
log := logger.NewStderrDebugLogger()
|
||||
|
||||
srv, serve, err := grpchelper.NewServer(authListenerFactory, clientIdentityKey, log)
|
||||
svc := &greeter{"hello "}
|
||||
pdu.RegisterGreeterServer(srv, svc)
|
||||
|
||||
if err := serve(); err != nil {
|
||||
onErr(err, "error serving")
|
||||
}
|
||||
}
|
||||
|
||||
type greeter struct {
|
||||
prepend string
|
||||
}
|
||||
|
||||
func (g *greeter) Greet(ctx context.Context, r *pdu.GreetRequest) (*pdu.GreetResponse, error) {
|
||||
ci, _ := ctx.Value(clientIdentityKey).(string)
|
||||
log.WithField("clientIdentity", ci).Info("Greet() request") // show that we got the client identity
|
||||
return &pdu.GreetResponse{Msg: fmt.Sprintf("%s%s (clientIdentity=%q)", g.prepend, r.GetName(), ci)}, nil
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// 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"
|
||||
)
|
||||
|
||||
// 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 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:"-"`
|
||||
}
|
||||
|
||||
func (m *GreetRequest) Reset() { *m = GreetRequest{} }
|
||||
func (m *GreetRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*GreetRequest) ProtoMessage() {}
|
||||
func (*GreetRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_1dfba7be0cf69353, []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
|
||||
}
|
||||
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:"-"`
|
||||
}
|
||||
|
||||
func (m *GreetResponse) Reset() { *m = GreetResponse{} }
|
||||
func (m *GreetResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*GreetResponse) ProtoMessage() {}
|
||||
func (*GreetResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_1dfba7be0cf69353, []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
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*GreetRequest)(nil), "pdu.GreetRequest")
|
||||
proto.RegisterType((*GreetResponse)(nil), "pdu.GreetResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("grpcauth.proto", fileDescriptor_1dfba7be0cf69353) }
|
||||
|
||||
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,
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
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 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,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "grpcauth.proto",
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// Package grpchelper wraps the adaptors implemented by package grpcclientidentity into a less flexible API
|
||||
// which, however, ensures that the individual adaptor primitive's expectations are met and hence do not panic.
|
||||
package grpchelper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
|
||||
"github.com/zrepl/zrepl/logger"
|
||||
"github.com/zrepl/zrepl/rpc/grpcclientidentity"
|
||||
"github.com/zrepl/zrepl/rpc/netadaptor"
|
||||
"github.com/zrepl/zrepl/transport"
|
||||
)
|
||||
|
||||
// The following constants are relevant for interoperability.
|
||||
// We use the same values for client & server, because zrepl is more
|
||||
// symmetrical ("one source, one sink") instead of the typical
|
||||
// gRPC scenario ("many clients, single server")
|
||||
const (
|
||||
StartKeepalivesAfterInactivityDuration = 5 * time.Second
|
||||
KeepalivePeerTimeout = 10 * time.Second
|
||||
)
|
||||
|
||||
type Logger = logger.Logger
|
||||
|
||||
// ClientConn is an easy-to-use wrapper around the Dialer and TransportCredentials interface
|
||||
// to produce a grpc.ClientConn
|
||||
func ClientConn(cn transport.Connecter, log Logger) *grpc.ClientConn {
|
||||
ka := grpc.WithKeepaliveParams(keepalive.ClientParameters{
|
||||
Time: StartKeepalivesAfterInactivityDuration,
|
||||
Timeout: KeepalivePeerTimeout,
|
||||
PermitWithoutStream: true,
|
||||
})
|
||||
dialerOption := grpc.WithDialer(grpcclientidentity.NewDialer(log, cn))
|
||||
cred := grpc.WithTransportCredentials(grpcclientidentity.NewTransportCredentials(log))
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
|
||||
defer cancel()
|
||||
cc, err := grpc.DialContext(ctx, "doesn't matter done by dialer", dialerOption, cred, ka)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("cannot create gRPC client conn (non-blocking)")
|
||||
// It's ok to panic here: the we call grpc.DialContext without the
|
||||
// (grpc.WithBlock) dial option, and at the time of writing, the grpc
|
||||
// docs state that no connection attempt is made in that case.
|
||||
// Hence, any error that occurs is due to DialOptions or similar,
|
||||
// and thus indicative of an implementation error.
|
||||
panic(err)
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// NewServer is a convenience interface around the TransportCredentials and Interceptors interface.
|
||||
func NewServer(authListenerFactory transport.AuthenticatedListenerFactory, clientIdentityKey interface{}, logger grpcclientidentity.Logger) (srv *grpc.Server, serve func() error, err error) {
|
||||
ka := grpc.KeepaliveParams(keepalive.ServerParameters{
|
||||
Time: StartKeepalivesAfterInactivityDuration,
|
||||
Timeout: KeepalivePeerTimeout,
|
||||
})
|
||||
tcs := grpcclientidentity.NewTransportCredentials(logger)
|
||||
unary, stream := grpcclientidentity.NewInterceptors(logger, clientIdentityKey)
|
||||
srv = grpc.NewServer(grpc.Creds(tcs), grpc.UnaryInterceptor(unary), grpc.StreamInterceptor(stream), ka)
|
||||
|
||||
serve = func() error {
|
||||
l, err := authListenerFactory()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := srv.Serve(netadaptor.New(l, logger)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return srv, serve, nil
|
||||
}
|
||||
Reference in New Issue
Block a user