Documentation ¶
Index ¶
- func ParseURI(s string) (string, bool, error)
- func SendUnary(cli *Client, info common.CallMethodInfo, req, resp message.Message, ...) error
- type CallOption
- type Client
- type Conn
- type MessageReadWriter
- type MessageReader
- type MessageReaderCloser
- type MessageWriter
- type MessageWriterCloser
- type Option
- func WithDialTimeout(v time.Duration) Option
- func WithGRPCConn(v Conn) Option
- func WithGRPCDialOptions(opts []grpc.DialOption) Option
- func WithNetworkAddress(v string) Option
- func WithNetworkURIAddress(addr string, tlsCfg *tls.Config) []Option
- func WithRWTimeout(v time.Duration) Option
- func WithTLSCfg(v *tls.Config) 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 CallOption ¶
type CallOption func(*callParameters)
CallOption is a messaging session option within Protobuf RPC.
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.
func WithDialer ¶
func WithDialer(dialer func(context.Context, grpc.ClientConnInterface) error) CallOption
WithDialer returns option to specify grpc dialer. If passed, it will be called after the connection is successfully created.
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.
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 Conn ¶
type Conn interface { grpc.ClientConnInterface io.Closer }
Conn is an interface for grpc client connection.
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 ¶
WithGRPCConn returns option to specify gRPC virtual connection.
func WithGRPCDialOptions ¶
func WithGRPCDialOptions(opts []grpc.DialOption) Option
WithGRPCDialOptions returns an option to specify grpc.DialOption.
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.