protoreflect: github.com/jhump/protoreflect/dynamic/grpcdynamic Index | Files

package grpcdynamic

import "github.com/jhump/protoreflect/dynamic/grpcdynamic"

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

Package Files

stub.go

type BidiStream Uses

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 Uses

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 Uses

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

Context returns the context associated with this streaming operation.

func (*BidiStream) Header Uses

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 Uses

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 Uses

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

SendMsg sends a request message to the server.

func (*BidiStream) Trailer Uses

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 Uses

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 Uses

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 Uses

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

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

func (*ClientStream) Context Uses

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

Context returns the context associated with this streaming operation.

func (*ClientStream) Header Uses

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 Uses

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

SendMsg sends a request message to the server.

func (*ClientStream) Trailer Uses

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 Uses

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 Uses

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

Context returns the context associated with this streaming operation.

func (*ServerStream) Header Uses

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 Uses

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 Uses

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 Uses

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

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

func NewStub Uses

func NewStub(channel Channel) Stub

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

func NewStubWithMessageFactory Uses

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 Uses

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 Uses

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 Uses

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 Uses

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.

Package grpcdynamic imports 8 packages (graph) and is imported by 14 packages. Updated 2020-03-24. Refresh now. Tools for package owners.