grpc

package
v2.0.0-...-15632a0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallOption

type CallOption func(*callParameters)

CallOption is a messaging session option within RPC.

func AllowBinarySendingOnly

func AllowBinarySendingOnly() CallOption

AllowBinarySendingOnly allows to pass []byte argument only to [MessageReadWriter.WriteMessage] method. By default, only proto.Message instances may be used. Use this option when binary message transmission is needed. Note that only proto.Message response messages are supported even with this option.

func WithContext

func WithContext(ctx context.Context) CallOption

WithContext returns option to set RPC context.

type Client

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

Client represents client for exchanging messages with a remote server using gRPC protocol.

func New

func New(opts ...Option) *Client

New creates, configures via options and returns new Client instance.

func (*Client) Conn

func (c *Client) Conn() io.Closer

Conn returns underlying connection.

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 within the RPC configured by options.

type Message

type Message interface{}

Message represents raw gRPC message.

type MessageReadWriter

type MessageReadWriter interface {
	// ReadMessage reads the next message from the remote server,
	// and writes it to the argument.
	ReadMessage(Message) error

	// WriteMessage sends message from argument to remote server.
	WriteMessage(Message) error

	// Closes the communication session with the remote server.
	//
	// All calls to send/receive messages must be done before closing.
	io.Closer
}

MessageReadWriter is a component interface for transmitting raw messages over gRPC protocol.

type Option

type Option func(*cfg)

Option is a Client's constructor option.

func WithClientConnection

func WithClientConnection(con *grpc.ClientConn) Option

WithClientConnection returns option to set gRPC connection to the remote server.

func WithRWTimeout

func WithRWTimeout(t time.Duration) Option

WithRWTimeout returns option to specify rwTimeout for reading and writing single gRPC message.

Jump to

Keyboard shortcuts

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