Documentation
¶
Index ¶
- type Config
- type LocalDispatch
- type SendResult
- type SenderOption
- func WithSenderBackendOptions(options ...morpc.BackendOption) SenderOption
- func WithSenderClientOptions(options ...morpc.ClientOption) SenderOption
- func WithSenderEnableCompress(enable bool) SenderOption
- func WithSenderLocalDispatch(localDispatch LocalDispatch) SenderOption
- func WithSenderMaxMessageSize(maxMessageSize int) SenderOption
- func WithSenderPayloadBufferSize(value int) SenderOption
- type ServerOption
- type TxnRequestHandleFunc
- type TxnSender
- type TxnServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.6.0
type Config struct {
// MaxConnections maximum number of connections to communicate with each DNStore.
// Default is 400.
MaxConnections int `toml:"max-connections"`
// MaxIdleDuration maximum connection idle time, connection will be closed automatically
// if this value is exceeded. Default is 1 min.
MaxIdleDuration toml.Duration `toml:"max-idle-duration"`
// SendQueueSize maximum capacity of the send request queue per connection, when the
// queue is full, the send request will be blocked. Default is 10240.
SendQueueSize int `toml:"send-queue-size"`
// BusyQueueSize when the length of the send queue reaches the currently set value, the
// current connection is busy with high load. When any connection with Busy status exists,
// a new connection will be created until the value set by MaxConnections is reached.
// Default is 3/4 of SendQueueSize.
BusyQueueSize int `toml:"busy-queue-size"`
// WriteBufferSize buffer size for write messages per connection. Default is 1kb
WriteBufferSize toml.ByteSize `toml:"write-buffer-size"`
// ReadBufferSize buffer size for read messages per connection. Default is 1kb
ReadBufferSize toml.ByteSize `toml:"read-buffer-size"`
// MaxMessageSize max size for read messages from dn. Default is 10M
MaxMessageSize toml.ByteSize `toml:"max-message-size"`
// EnableCompress enable compress message
EnableCompress bool `toml:"enable-compress"`
}
Config txn sender config
type LocalDispatch ¶
type LocalDispatch func(metadata.DNShard) TxnRequestHandleFunc
LocalDispatch used to returns request handler on local, avoid rpc
type SendResult ¶ added in v0.5.1
type SendResult struct {
Responses []txn.TxnResponse
// contains filtered or unexported fields
}
SendResult wrapping []txn.TxnResponse for reuse
func (*SendResult) Release ¶ added in v0.5.1
func (sr *SendResult) Release()
Release release send result
type SenderOption ¶
type SenderOption func(*sender)
SenderOption option for create Sender
func WithSenderBackendOptions ¶
func WithSenderBackendOptions(options ...morpc.BackendOption) SenderOption
WithSenderBackendOptions set options for create backend connections
func WithSenderClientOptions ¶
func WithSenderClientOptions(options ...morpc.ClientOption) SenderOption
WithSenderClientOptions set options for create client
func WithSenderEnableCompress ¶ added in v0.7.0
func WithSenderEnableCompress(enable bool) SenderOption
WithSenderEnableCompress enable compress
func WithSenderLocalDispatch ¶
func WithSenderLocalDispatch(localDispatch LocalDispatch) SenderOption
WithSenderLocalDispatch set options for dispatch request to local to avoid rpc call
func WithSenderMaxMessageSize ¶ added in v0.6.0
func WithSenderMaxMessageSize(maxMessageSize int) SenderOption
WithSenderMaxMessageSize set max rpc message size
func WithSenderPayloadBufferSize ¶
func WithSenderPayloadBufferSize(value int) SenderOption
WithSenderPayloadBufferSize set buffer size for copy payload data to socket.
type ServerOption ¶ added in v0.6.0
type ServerOption func(*server)
ServerOption option for create TxnServer
func WithServerEnableCompress ¶ added in v0.7.0
func WithServerEnableCompress(enable bool) ServerOption
WithServerEnableCompress enable compress
func WithServerMaxMessageSize ¶ added in v0.6.0
func WithServerMaxMessageSize(maxMessageSize int) ServerOption
WithServerMaxMessageSize set max rpc message size
func WithServerMessageFilter ¶ added in v0.6.0
func WithServerMessageFilter(filter func(*txn.TxnRequest) bool) ServerOption
set filter func. Requests can be modified or filtered out by the filter before they are processed by the handler.
type TxnRequestHandleFunc ¶
type TxnRequestHandleFunc func(context.Context, *txn.TxnRequest, *txn.TxnResponse) error
TxnRequestHandleFunc txn request handle func
type TxnSender ¶
type TxnSender interface {
// Send send request to the specified DN node, and wait for response synchronously.
// For any reason, if no response is received, the internal will keep retrying until
// the Context times out.
Send(context.Context, []txn.TxnRequest) (*SendResult, error)
// Close the txn sender
Close() error
}
TxnSender is used to send transaction requests to the DN nodes.
func NewSender ¶
func NewSender( rt moruntime.Runtime, options ...SenderOption) (TxnSender, error)
NewSender create a txn sender
func NewSenderWithConfig ¶ added in v0.6.0
func NewSenderWithConfig(cfg Config, rt moruntime.Runtime, options ...SenderOption) (TxnSender, error)
NewSenderWithConfig create a txn sender by config and options
type TxnServer ¶
type TxnServer interface {
// Start start the txn server
Start() error
// Close the txn server
Close() error
// RegisterMethodHandler register txn request handler func
RegisterMethodHandler(txn.TxnMethod, TxnRequestHandleFunc)
}
TxnServer receives and processes txn requests from TxnSender.
func NewTxnServer ¶
NewTxnServer create a txn server. One DNStore corresponds to one TxnServer