Add functions to ClientConn so it satisfies an interface for generated code (#1599)
This commit is contained in:
15
call.go
15
call.go
@ -125,16 +125,23 @@ func sendRequest(ctx context.Context, dopts dialOptions, compressor Compressor,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke sends the RPC request on the wire and returns after response is received.
|
// Invoke sends the RPC request on the wire and returns after response is
|
||||||
// Invoke is called by generated code. Also users can call Invoke directly when it
|
// received. This is typically called by generated code.
|
||||||
// is really needed in their use cases.
|
func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...CallOption) error {
|
||||||
func Invoke(ctx context.Context, method string, args, reply interface{}, cc *ClientConn, opts ...CallOption) error {
|
|
||||||
if cc.dopts.unaryInt != nil {
|
if cc.dopts.unaryInt != nil {
|
||||||
return cc.dopts.unaryInt(ctx, method, args, reply, cc, invoke, opts...)
|
return cc.dopts.unaryInt(ctx, method, args, reply, cc, invoke, opts...)
|
||||||
}
|
}
|
||||||
return invoke(ctx, method, args, reply, cc, opts...)
|
return invoke(ctx, method, args, reply, cc, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invoke sends the RPC request on the wire and returns after response is
|
||||||
|
// received. This is typically called by generated code.
|
||||||
|
//
|
||||||
|
// DEPRECATED: Use ClientConn.Invoke instead.
|
||||||
|
func Invoke(ctx context.Context, method string, args, reply interface{}, cc *ClientConn, opts ...CallOption) error {
|
||||||
|
return cc.Invoke(ctx, method, args, reply, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
func invoke(ctx context.Context, method string, args, reply interface{}, cc *ClientConn, opts ...CallOption) (e error) {
|
func invoke(ctx context.Context, method string, args, reply interface{}, cc *ClientConn, opts ...CallOption) (e error) {
|
||||||
c := defaultCallInfo()
|
c := defaultCallInfo()
|
||||||
mc := cc.GetMethodConfig(method)
|
mc := cc.GetMethodConfig(method)
|
||||||
|
24
rpc_util.go
24
rpc_util.go
@ -439,19 +439,19 @@ func Errorf(c codes.Code, format string, a ...interface{}) error {
|
|||||||
return status.Errorf(c, format, a...)
|
return status.Errorf(c, format, a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SupportPackageIsVersion3 is referenced from generated protocol buffer files.
|
// The SupportPackageIsVersion variables are referenced from generated protocol
|
||||||
// The latest support package version is 4.
|
// buffer files to ensure compatibility with the gRPC version used. The latest
|
||||||
// SupportPackageIsVersion3 is kept for compatibility. It will be removed in the
|
// support package version is 5.
|
||||||
// next support package version update.
|
|
||||||
const SupportPackageIsVersion3 = true
|
|
||||||
|
|
||||||
// SupportPackageIsVersion4 is referenced from generated protocol buffer files
|
|
||||||
// to assert that that code is compatible with this version of the grpc package.
|
|
||||||
//
|
//
|
||||||
// This constant may be renamed in the future if a change in the generated code
|
// Older versions are kept for compatibility. They may be removed if
|
||||||
// requires a synchronised update of grpc-go and protoc-gen-go. This constant
|
// compatibility cannot be maintained.
|
||||||
// should not be referenced from any other code.
|
//
|
||||||
const SupportPackageIsVersion4 = true
|
// These constants should not be referenced from any other code.
|
||||||
|
const (
|
||||||
|
SupportPackageIsVersion3 = true
|
||||||
|
SupportPackageIsVersion4 = true
|
||||||
|
SupportPackageIsVersion5 = true
|
||||||
|
)
|
||||||
|
|
||||||
// Version is the current grpc version.
|
// Version is the current grpc version.
|
||||||
const Version = "1.8.0-dev"
|
const Version = "1.8.0-dev"
|
||||||
|
14
stream.go
14
stream.go
@ -94,15 +94,23 @@ type ClientStream interface {
|
|||||||
Stream
|
Stream
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClientStream creates a new Stream for the client side. This is called
|
// NewStream creates a new Stream for the client side. This is typically
|
||||||
// by generated code.
|
// called by generated code.
|
||||||
func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (_ ClientStream, err error) {
|
func (cc *ClientConn) NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error) {
|
||||||
if cc.dopts.streamInt != nil {
|
if cc.dopts.streamInt != nil {
|
||||||
return cc.dopts.streamInt(ctx, desc, cc, method, newClientStream, opts...)
|
return cc.dopts.streamInt(ctx, desc, cc, method, newClientStream, opts...)
|
||||||
}
|
}
|
||||||
return newClientStream(ctx, desc, cc, method, opts...)
|
return newClientStream(ctx, desc, cc, method, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewClientStream creates a new Stream for the client side. This is typically
|
||||||
|
// called by generated code.
|
||||||
|
//
|
||||||
|
// DEPRECATED: Use ClientConn.NewStream instead.
|
||||||
|
func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) {
|
||||||
|
return cc.NewStream(ctx, desc, method, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (_ ClientStream, err error) {
|
func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (_ ClientStream, err error) {
|
||||||
var (
|
var (
|
||||||
t transport.ClientTransport
|
t transport.ClientTransport
|
||||||
|
Reference in New Issue
Block a user