Documentation ¶
Index ¶
- func ParseURI(s string) (string, bool, error)
- func SendUnary(cli *Client, info common.CallMethodInfo, req, resp message.Message, ...) error
- type BinaryMessage
- type CallOption
- type Client
- type MessageReadWriter
- type MessageReader
- type MessageReaderCloser
- type MessageWriter
- type MessageWriterCloser
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseURI ¶
ParseURI parses s as address and returns a host and a flag indicating that TLS is enabled. If multi-address is provided the argument is returned unchanged.
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 BinaryMessage ¶
type BinaryMessage []byte
BinaryMessage represents binary message.Message that can be used with AllowBinarySendingOnly option.
func (BinaryMessage) FromGRPCMessage ¶
func (x BinaryMessage) FromGRPCMessage(m grpc.Message) error
func (BinaryMessage) ToGRPCMessage ¶
func (x BinaryMessage) ToGRPCMessage() grpc.Message
type CallOption ¶
type CallOption func(*callParameters)
CallOption is a messaging session option within Protobuf RPC.
func AllowBinarySendingOnly ¶
func AllowBinarySendingOnly() CallOption
AllowBinarySendingOnly allows only [MessageWriter.WriteMessage] method's arguments that are convertible to binary gRPC messages ([]byte). For example, BinaryMessage may be used for such write. By default, only arguments convertible to [proto.Message] may be used. Use this option when binary message transmission is needed. Note that only [proto.Message] convertible response messages are supported even with this option.
func WithContext ¶
func WithContext(ctx context.Context) CallOption
WithContext returns option to specify call context. If provided, all network communications will be based on this context. Otherwise, context.Background() is used.
Context SHOULD NOT be nil.
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) Conn ¶
Conn returns underlying connection.
Returns non-nil result after the first Init() call completed without a connection error.
Conn is NPE-safe: returns nil if Client is nil.
Client should not be used after Close() call on the connection: behavior is undefined.
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.
func WithNetworkURIAddress ¶
WithNetworkURIAddress combines WithNetworkAddress and WithTLSCfg options based on arguments.
Do not use along with WithNetworkAddress and WithTLSCfg.
Ignored if WithGRPCConn is provided.
func WithRWTimeout ¶
WithRWTimeout returns option to specify timeout for reading and writing single gRPC message.
func WithTLSCfg ¶
WithTLSCfg returns option to specify TLS configuration.
Ignored if WithGRPCConn is provided.