Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendUnary ¶
func SendUnary(cli *Client, info common.CallMethodInfo, req, resp message.Message, opts ...CallOption) error
SendUnary initializes communication session by RPC info, performs unary RPC and closes the session.
Types ¶
type CallOption ¶
type CallOption func(*callParameters)
CallOption is a messaging session option within Protobuf RPC.
func WithContext ¶
func WithContext(ctx context.Context) CallOption
WithContext return options to specify call context.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents client for exchanging messages with a remote server using Protobuf RPC.
func (*Client) Init ¶
func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageReadWriter, error)
Init initiates a messaging session and returns the interface for message transmitting.
type MessageReadWriter ¶
type MessageReadWriter interface {
MessageReader
MessageWriter
// Closes the communication session.
//
// All calls to send/receive messages must be done before closing.
io.Closer
}
MessageReadWriter is a component interface for transmitting raw Protobuf messages.
type MessageReader ¶
type MessageReader interface {
// ReadMessage reads the next Message.
//
// Returns io.EOF if there are no more messages to read.
// ReadMessage should not be called after io.EOF occasion.
ReadMessage(message.Message) error
}
MessageReader is an interface of the Message reader.
func OpenServerStream ¶
func OpenServerStream(cli *Client, info common.CallMethodInfo, req message.Message, opts ...CallOption) (MessageReader, error)
OpenServerStream initializes communication session by RPC info, opens server-side stream and returns its interface.
All stream reads must be performed before the closing. Close must be called once.
type MessageReaderCloser ¶
type MessageReaderCloser interface {
MessageReader
io.Closer
}
MessageReaderCloser wraps MessageReader and io.Closer interface.
type MessageWriter ¶
type MessageWriter interface {
// WriteMessage writers the next Message.
//
// WriteMessage should not be called after any error.
WriteMessage(message.Message) error
}
MessageWriter is an interface of the Message writer.
type MessageWriterCloser ¶
type MessageWriterCloser interface {
MessageWriter
io.Closer
}
MessageWriterCloser wraps MessageWriter and io.Closer interfaces.
func OpenClientStream ¶
func OpenClientStream(cli *Client, info common.CallMethodInfo, resp message.Message, opts ...CallOption) (MessageWriterCloser, error)
OpenClientStream initializes communication session by RPC info, opens client-side stream and returns its interface.
All stream writes must be performed before the closing. Close must be called once.
type Option ¶
type Option func(*cfg)
Option is a Client's option.
func WithDialTimeout ¶
WithDialTimeout returns option to specify dial timeout of the remote server connection.
Ignored if WithGRPCConn is provided.
func WithGRPCConn ¶
func WithGRPCConn(v *grpc.ClientConn) Option
WithGRPCConn returns option to specify gRPC virtual connection.
func WithNetworkAddress ¶
WithNetworkAddress returns option to specify network address of the remote server.
Ignored if WithGRPCConn is provided.