rpc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package rpc contains the RPC client implementation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidXID is returned when an invalid xID is received.
	ErrInvalidXID = errors.New("invalid xID")
	// ErrInvalidResponse is returned when an invalid response is received.
	ErrInvalidResponse = errors.New("invalid response")
	// ErrNoReplyFrame is returned when no reply frame is received. It wraps ErrInvalidResponse.
	ErrNoReplyFrame = fmt.Errorf("%w: no reply frame received", ErrInvalidResponse)
	// ErrProgramMismatch is returned when the program does not match.
	ErrProgramMismatch = errors.New("program mismatch")
	// ErrProcedureUnavailable is returned when the procedure is unavailable.
	ErrProcedureUnavailable = errors.New("procedure unavailable")
	// ErrRPCMismatch is returned when the RPC does not match.
	ErrRPCMismatch = errors.New("rpc mismatch")
	// ErrAuthError is returned when an authentication error occurs.
	ErrAuthError = errors.New("auth error")
)

Functions

func Call

func Call[C any, R ReturnCoder](client *m1client.Client, module Module, procedure Procedure[C, R]) (*R, error)

Call sends an RPC call to the target with the given header and procedure. It packs and unpacks the call and reply objects and checks for errors.

func PaginatedCall added in v0.2.0

func PaginatedCall[T any, C PaginatedCaller, R PaginatedReturnCoder[T]](
	client *m1client.Client, module Module, procedure PaginatedProcedure[T, C, R], pageSize uint32,
) ([]T, error)

Types

type Count added in v0.2.0

type Count uint32

func (Count) GetCount added in v0.2.0

func (c Count) GetCount() uint32

func (*Count) SetCount added in v0.2.0

func (c *Count) SetCount(count uint32)
type Header struct {
	Module    uint32
	Version   Version
	Procedure uint32
	Auth      []byte
	// contains filtered or unexported fields
}

Header contains the header of an RPC call.

type Module added in v0.2.0

type Module struct {
	Number uint32
	Port   uint16
}

type PaginatedCallCountStart added in v0.2.0

type PaginatedCallCountStart struct {
	Count
	Start
}

type PaginatedCallFirstLast added in v0.2.0

type PaginatedCallFirstLast struct {
	Start
	// contains filtered or unexported fields
}

func (*PaginatedCallFirstLast) SetCount added in v0.2.0

func (l *PaginatedCallFirstLast) SetCount(count uint32)

type PaginatedCallStartCount added in v0.2.0

type PaginatedCallStartCount struct {
	Start
	Count
}

type PaginatedCaller added in v0.2.0

type PaginatedCaller interface {
	SetStart(uint32)
	SetCount(uint32)
}

type PaginatedProcedure added in v0.2.0

type PaginatedProcedure[T any, C PaginatedCaller, R PaginatedReplier[T]] struct {
	Call C
	// contains filtered or unexported fields
}

func NewPaginatedProcedure added in v0.2.0

func NewPaginatedProcedure[T any, C PaginatedCaller, R PaginatedReturnCoder[T]](
	procedure uint32, version Version, call C,
) PaginatedProcedure[T, C, R]

func (PaginatedProcedure[T, C, R]) Procedure added in v0.2.0

func (p PaginatedProcedure[T, C, R]) Procedure() uint32

func (PaginatedProcedure[T, C, R]) RPCVersion added in v0.2.0

func (p PaginatedProcedure[T, C, R]) RPCVersion() Version

type PaginatedReplier added in v0.2.0

type PaginatedReplier[T any] interface {
	GetCount() uint32
	Done(uint32) bool
	GetValues() []T
}

type PaginatedReplyContinuationCount added in v0.2.0

type PaginatedReplyContinuationCount[T any] struct {
	ContinuationPoint uint32 `m1binary:"skip:12"`
	Count
	Values[T] `m1binary:"lengthRef:Count,allign4"`
}

func (PaginatedReplyContinuationCount[T]) Done added in v0.2.0

type PaginatedReplyCount added in v0.2.0

type PaginatedReplyCount[T any] struct {
	Count
	Values[T] `m1binary:"lengthRef:Count"`
}

func (PaginatedReplyCount[T]) Done added in v0.2.0

func (l PaginatedReplyCount[T]) Done(step uint32) bool

type PaginatedReturnCoder added in v0.2.0

type PaginatedReturnCoder[T any] interface {
	ReturnCoder
	PaginatedReplier[T]
}

type Procedure

type Procedure[C any, R ReturnCoder] struct {
	Call C
	// contains filtered or unexported fields
}

func NewProcedure

func NewProcedure[C any, R ReturnCoder](procedure uint32, version Version, call C) Procedure[C, R]

func (Procedure[C, R]) Procedure

func (p Procedure[C, R]) Procedure() uint32

func (Procedure[C, R]) RPCVersion

func (p Procedure[C, R]) RPCVersion() Version

type ReturnCode

type ReturnCode int32

func (ReturnCode) GetReturnCode

func (r ReturnCode) GetReturnCode() uint32

type ReturnCoder

type ReturnCoder interface {
	GetReturnCode() uint32
}

type Start added in v0.2.0

type Start uint32

func (*Start) SetStart added in v0.2.0

func (f *Start) SetStart(start uint32)

type Values added in v0.2.0

type Values[T any] []T

func (Values[T]) GetValues added in v0.2.0

func (v Values[T]) GetValues() []T

type Version

type Version uint32
const (
	VersionDefault Version = 2
	VersionRES     Version = 3
)

Jump to

Keyboard shortcuts

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