package
1.2.3
Repository: https://github.com/matrixorigin/matrixone.git
Documentation: pkg.go.dev

# README

morpc

The morpc is a Goetty wrapper based message communication framework. Based on morpc, you can implement Request-Response, Stream two types of communication.

Components

morpc consists of RPCClient and RPCServer. RPCClient is used to send messages and RPCServer is used to process and respond to request messages.

RPCClient

An RPCClient can manage multiple underlying tcp connections, which we call Backend. Each Backend will start two gortoutines to handle the IO reads and writes. A server address can correspond to more than one Backend, and load balancing by way of RoundRobin.

RPCServer

RPCServer can listen to a TCP address or a UnixSocket.After a client connects, the RPCServer allocates two co-processes to handle the IO reads and writes.When RPCServer is started, it will set a message processing Handler, which will be invoked whenever a message is received from a client, and the specific logic of message processing needs to be implemented in the Handler.

Examples

# Packages

No description provided by the author
Package mock_morpc is a generated GoMock package.

# Functions

No description provided by the author
NewClient create rpc client with options.
No description provided by the author
NewMessageCodec create message codec.
NewMessageHandler create a message handler.
NewMessagePool create message pool.
NewRemoteBackend create a goetty connection based backend.
NewRPCServer create rpc server with options.
WithBackendBatchSendSize set the maximum number of messages to be sent together at each batch.
WithBackendBufferSize set the buffer size of the wait send chan.
WithBackendBusyBufferSize if len(writeC) >= size, backend is busy.
WithBackendConnectTimeout set the timeout for connect to remote.
WithBackendFilter set send filter func.
WithBackendFreeOrphansResponse setup free orphans response func.
WithBackendGoettyOptions set goetty connection options.
WithBackendHasPayloadResponse has payload response means read a response that hold a slice of data in the read buffer to avoid data copy.
WithBackendLogger set the backend logger.
WithBackendMetrics setup backend metrics.
WithBackendReadTimeout set read timeout for read loop.
WithBackendStreamBufferSize set buffer size for stream receive message chan.
WithClientCreateTaskChanSize set the buffer size of the chan that creates the Backend Task.
WithClientEnableAutoCreateBackend enable client to automatically create a backend in the background, when the links in the connection pool are used, if the pool has not reached the maximum number of links, it will automatically create them in the background to improve the latency of link creation.
WithClientInitBackends set the number of connections for the initialized backends.
WithClientLogger set client logger.
WithClientMaxBackendMaxIdleDuration set the maximum idle duration of the backend connection.
WithClientMaxBackendPerHost maximum number of connections per host.
WithCodecEnableChecksum enable checksum.
WithCodecEnableCompress enable compress body and payload.
WithCodecIntegrationHLC intrgration hlc.
WithCodecMaxBodySize set rpc max body size.
WithCodecPayloadCopyBufferSize set payload copy buffer size, if is a PayloadMessage.
WithDisconnectAfterRead used for testing.
WithHandleMessageFilter set filter func.
WithHandlerRespReleaseFunc sets the respReleaseFunc of the handler.
WithServerBatchSendSize set the maximum number of messages to be sent together at each batch.
WithServerDisableAutoCancelContext disable automatic cancel messaging for the context.
WithServerGoettyOptions set write filter func.
WithServerLogger set rpc server logger.
WithServerSessionBufferSize set the buffer size of the write response chan.
WithServerWriteFilter set write filter func.

# Structs

Config rpc client config.
Future is used to obtain response data synchronously.
RPCMessage any message sent via morpc needs to have a Context set, which is transmitted across the network.

# Interfaces

Backend backend represents a wrapper for a client communicating with a remote server.
BackendFactory backend factory.
ClientSession client session, which is used to send the response message.
Codec codec.
HeaderCodec encode and decode header.
Message morpc is not a normal remote method call, rather it is a message-based asynchronous driven framework.
MessageCache the client uses stream to send messages to the server, and when the server thinks it has not received enough messages, it can cache the messages sent by the client.
MessageHandler receives and handle requests from client.
MessagePool message pool is used to reuse request and response to avoid allocate.
MethodBasedMessage defines messages based on Request and Response patterns in RPC.
PayloadMessage is similar message, but has a large payload field.
RPCClient morpc is not a normal remote method call, rather it is a message-based asynchronous driven framework.
RPCServer RPC server implementation corresponding to RPCClient.
Stream used to asynchronous stream of sending and receiving messages.

# Type aliases

BackendOption options for create remote backend.
ClientOption client options for create client.
CodecOption codec options.
HandleFunc request handle func.
HandlerOption message handler option.
ServerOption server options for create rpc server.