grpcdynamic

package
v1.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2020 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package grpcdynamic provides a dynamic RPC stub. It can be used to invoke RPC method where only method descriptors are known. The actual request and response messages may be dynamic messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BidiStream

type BidiStream struct {
	// contains filtered or unexported fields
}

BidiStream represents a bi-directional stream for sending messages to and receiving messages from a server. The header and trailer metadata sent by the server can also be queried.

func (*BidiStream) CloseSend

func (s *BidiStream) CloseSend() error

CloseSend indicates the request stream has ended. Invoke this after all request messages are sent (even if there are zero such messages).

func (*BidiStream) Context

func (s *BidiStream) Context() context.Context

Context returns the context associated with this streaming operation.

func (*BidiStream) Header

func (s *BidiStream) Header() (metadata.MD, error)

Header returns any header metadata sent by the server (blocks if necessary until headers are received).

func (*BidiStream) RecvMsg

func (s *BidiStream) RecvMsg() (proto.Message, error)

RecvMsg returns the next message in the response stream or an error. If the stream has completed normally, the error is io.EOF. Otherwise, the error indicates the nature of the abnormal termination of the stream.

func (*BidiStream) SendMsg

func (s *BidiStream) SendMsg(m proto.Message) error

SendMsg sends a request message to the server.

func (*BidiStream) Trailer

func (s *BidiStream) Trailer() metadata.MD

Trailer returns the trailer metadata sent by the server. It must only be called after RecvMsg returns a non-nil error (which may be EOF for normal completion of stream).

type Channel

type Channel interface {
	Invoke(ctx context.Context, method string, args, reply interface{}, opts ...grpc.CallOption) error
	NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
}

Channel represents the operations necessary to issue RPCs via gRPC. The *grpc.ClientConn type provides this interface and will typically the concrete type used to construct Stubs. But the use of this interface allows construction of stubs that use alternate concrete types as the transport for RPC operations.

type ClientStream

type ClientStream struct {
	// contains filtered or unexported fields
}

ClientStream represents a response stream from a client. Messages in the stream can be sent and, when done, the unary server message and header and trailer metadata can be queried.

func (*ClientStream) CloseAndReceive

func (s *ClientStream) CloseAndReceive() (proto.Message, error)

CloseAndReceive closes the outgoing request stream and then blocks for the server's response.

func (*ClientStream) Context

func (s *ClientStream) Context() context.Context

Context returns the context associated with this streaming operation.

func (*ClientStream) Header

func (s *ClientStream) Header() (metadata.MD, error)

Header returns any header metadata sent by the server (blocks if necessary until headers are received).

func (*ClientStream) SendMsg

func (s *ClientStream) SendMsg(m proto.Message) error

SendMsg sends a request message to the server.

func (*ClientStream) Trailer

func (s *ClientStream) Trailer() metadata.MD

Trailer returns the trailer metadata sent by the server. It must only be called after RecvMsg returns a non-nil error (which may be EOF for normal completion of stream).

type ServerStream

type ServerStream struct {
	// contains filtered or unexported fields
}

ServerStream represents a response stream from a server. Messages in the stream can be queried as can header and trailer metadata sent by the server.

func (*ServerStream) Context

func (s *ServerStream) Context() context.Context

Context returns the context associated with this streaming operation.

func (*ServerStream) Header

func (s *ServerStream) Header() (metadata.MD, error)

Header returns any header metadata sent by the server (blocks if necessary until headers are received).

func (*ServerStream) RecvMsg

func (s *ServerStream) RecvMsg() (proto.Message, error)

RecvMsg returns the next message in the response stream or an error. If the stream has completed normally, the error is io.EOF. Otherwise, the error indicates the nature of the abnormal termination of the stream.

func (*ServerStream) Trailer

func (s *ServerStream) Trailer() metadata.MD

Trailer returns the trailer metadata sent by the server. It must only be called after RecvMsg returns a non-nil error (which may be EOF for normal completion of stream).

type Stub

type Stub struct {
	// contains filtered or unexported fields
}

Stub is an RPC client stub, used for dynamically dispatching RPCs to a server.

func NewStub

func NewStub(channel Channel) Stub

NewStub creates a new RPC stub that uses the given channel for dispatching RPCs.

func NewStubWithMessageFactory

func NewStubWithMessageFactory(channel Channel, mf *dynamic.MessageFactory) Stub

NewStubWithMessageFactory creates a new RPC stub that uses the given channel for dispatching RPCs and the given MessageFactory for creating response messages.

func (Stub) InvokeRpc

func (s Stub) InvokeRpc(ctx context.Context, method *desc.MethodDescriptor, request proto.Message, opts ...grpc.CallOption) (proto.Message, error)

InvokeRpc sends a unary RPC and returns the response. Use this for unary methods.

func (Stub) InvokeRpcBidiStream

func (s Stub) InvokeRpcBidiStream(ctx context.Context, method *desc.MethodDescriptor, opts ...grpc.CallOption) (*BidiStream, error)

InvokeRpcBidiStream creates a new stream that is used to both send request messages and receive response messages. Use this for bidi-streaming methods.

func (Stub) InvokeRpcClientStream

func (s Stub) InvokeRpcClientStream(ctx context.Context, method *desc.MethodDescriptor, opts ...grpc.CallOption) (*ClientStream, error)

InvokeRpcClientStream creates a new stream that is used to send request messages and, at the end, receive the response message. Use this for client-streaming methods.

func (Stub) InvokeRpcServerStream

func (s Stub) InvokeRpcServerStream(ctx context.Context, method *desc.MethodDescriptor, request proto.Message, opts ...grpc.CallOption) (*ServerStream, error)

InvokeRpcServerStream sends a unary RPC and returns the response stream. Use this for server-streaming methods.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL