rpc

package
v0.97.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package rpc implements rpc engine.

Index

Constants

This section is empty.

Variables

View Source
var ErrEngineClosed = errors.New("engine was closed")

ErrEngineClosed means that engine was closed.

Functions

func NopDrop added in v0.50.0

func NopDrop(Request) error

NopDrop does nothing.

func NopSend

NopSend does nothing.

Types

type DropHandler added in v0.25.0

type DropHandler func(req Request) error

DropHandler handles drop rpc requests.

type Engine

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

Engine handles RPC requests.

func New

func New(send Send, cfg Options) *Engine

New creates new rpc Engine.

func (*Engine) Close

func (e *Engine) Close()

Close gracefully closes the engine. All pending requests will be awaited. All Do method calls of closed engine will return ErrEngineClosed error.

func (*Engine) Do

func (e *Engine) Do(ctx context.Context, req Request) error

Do sends request to server and blocks until response is received, performing multiple retries if needed.

func (*Engine) ForceClose added in v0.21.2

func (e *Engine) ForceClose()

ForceClose forcibly closes the engine. All pending requests will be canceled. All Do method calls of closed engine will return ErrEngineClosed error.

func (*Engine) NotifyAcks

func (e *Engine) NotifyAcks(ids []int64)

NotifyAcks notifies engine about received acknowledgements.

func (*Engine) NotifyError

func (e *Engine) NotifyError(msgID int64, rpcErr error)

NotifyError notifies engine about received RPC error.

func (*Engine) NotifyResult

func (e *Engine) NotifyResult(msgID int64, b *bin.Buffer) error

NotifyResult notifies engine about received RPC response.

type Options

type Options struct {
	RetryInterval time.Duration
	MaxRetries    int
	Logger        *zap.Logger
	Clock         clock.Clock
	DropHandler   DropHandler
}

Options of rpc engine.

type Request

type Request struct {
	MsgID  int64
	SeqNo  int32
	Input  bin.Encoder
	Output bin.Decoder
}

Request represents client RPC request.

type RetryLimitReachedErr

type RetryLimitReachedErr struct {
	Retries int
}

RetryLimitReachedErr means that server does not acknowledge request after multiple retries.

func (*RetryLimitReachedErr) Error

func (r *RetryLimitReachedErr) Error() string

func (*RetryLimitReachedErr) Is

func (r *RetryLimitReachedErr) Is(err error) bool

Is reports whether err is RetryLimitReachedErr.

type Send

type Send func(ctx context.Context, msgID int64, seqNo int32, in bin.Encoder) error

Send is a function that sends requests to the server.

Jump to

Keyboard shortcuts

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