rpc

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: LGPL-2.1 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Name      = plugin.Name
	Using     = plugin.Using
	Install   = plugin.Install
	Uninstall = plugin.Uninstall
)
View Source
var (
	ErrPluginNotFound               = errors.New("rpc: plugin not found")
	ErrMethodNotFound               = errors.New("rpc: method not found")
	ErrComponentNotFound            = errors.New("rpc: component not found")
	ErrMethodParameterCountMismatch = errors.New("rpc: method parameter count mismatch")
	ErrMethodParameterTypeMismatch  = errors.New("rpc: method parameter type mismatch")
)
View Source
var (
	ErrMethodResultCountMismatch = errors.New("rpc: method result count mismatch")
	ErrMethodResultTypeMismatch  = errors.New("rpc: method result type mismatch")
)
View Source
var (
	ErrNoDeliverer = errors.New("rpc: no deliverer") // 没有匹配的投递器
)

Functions

func OneWayRPC

func OneWayRPC(servCtx service.Context, dst, path string, args ...any) error

OneWayRPC 单向RPC调用

func RPC

func RPC(servCtx service.Context, dst, path string, args ...any) runtime.AsyncRet

RPC RPC调用

func Result1 added in v0.1.20

func Result1[T1 any](ret runtime.Ret) (T1, error)

func Result10 added in v0.1.20

func Result10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, error)

func Result11 added in v0.1.20

func Result11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, error)

func Result12 added in v0.1.20

func Result12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, error)

func Result13 added in v0.1.20

func Result13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, error)

func Result14 added in v0.1.20

func Result14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, error)

func Result15 added in v0.1.20

func Result15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, error)

func Result16 added in v0.1.20

func Result16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, error)

func Result2 added in v0.1.20

func Result2[T1, T2 any](ret runtime.Ret) (T1, T2, error)

func Result3 added in v0.1.20

func Result3[T1, T2, T3 any](ret runtime.Ret) (T1, T2, T3, error)

func Result4 added in v0.1.20

func Result4[T1, T2, T3, T4 any](ret runtime.Ret) (T1, T2, T3, T4, error)

func Result5 added in v0.1.20

func Result5[T1, T2, T3, T4, T5 any](ret runtime.Ret) (T1, T2, T3, T4, T5, error)

func Result6 added in v0.1.20

func Result6[T1, T2, T3, T4, T5, T6 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, error)

func Result7 added in v0.1.20

func Result7[T1, T2, T3, T4, T5, T6, T7 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, error)

func Result8 added in v0.1.20

func Result8[T1, T2, T3, T4, T5, T6, T7, T8 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, error)

func Result9 added in v0.1.20

func Result9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any](ret runtime.Ret) (T1, T2, T3, T4, T5, T6, T7, T8, T9, error)

func ResultVoid added in v0.1.20

func ResultVoid(ret runtime.Ret) error

func Results

func Results(ret runtime.Ret) ([]any, error)

Types

type DistributedDeliverer

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

DistributedDeliverer 分布式服务的RPC投递器

func (*DistributedDeliverer) Init

func (d *DistributedDeliverer) Init(ctx service.Context)

Init 初始化

func (*DistributedDeliverer) Match

func (d *DistributedDeliverer) Match(ctx service.Context, dst, path string, oneWay bool) bool

Match 是否匹配

func (*DistributedDeliverer) Notify

func (d *DistributedDeliverer) Notify(ctx service.Context, dst, path string, args []any) error

Notify 通知

func (*DistributedDeliverer) Request

func (d *DistributedDeliverer) Request(ctx service.Context, dst, path string, args []any) runtime.AsyncRet

Request 请求

func (*DistributedDeliverer) Shut

func (d *DistributedDeliverer) Shut(ctx service.Context)

Shut 结束

type DistributedDispatcher

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

DistributedDispatcher 分布式服务的RPC分发器

func (*DistributedDispatcher) Init

func (d *DistributedDispatcher) Init(ctx service.Context)

Init 初始化

func (*DistributedDispatcher) Shut

func (d *DistributedDispatcher) Shut(ctx service.Context)

Shut 结束

type IDeliverer

type IDeliverer interface {
	// Match 是否匹配
	Match(ctx service.Context, dst, path string, oneWay bool) bool
	// Request 请求
	Request(ctx service.Context, dst, path string, args []any) runtime.AsyncRet
	// Notify 通知
	Notify(ctx service.Context, dst, path string, args []any) error
}

IDeliverer RPC投递器接口,用于将RPC投递至目标

type IDispatcher

type IDispatcher any

IDispatcher RPC分发器接口,用于分发RPC请求与响应

type IRPC

type IRPC interface {
	// RPC RPC调用
	RPC(dst, path string, args ...any) runtime.AsyncRet
	// OneWayRPC 单向RPC调用
	OneWayRPC(dst, path string, args ...any) error
}

IRPC RPC支持

type LifecycleInit

type LifecycleInit interface {
	Init(ctx service.Context)
}

LifecycleInit 生命周期开始

type LifecycleShut

type LifecycleShut interface {
	Shut(ctx service.Context)
}

LifecycleShut 生命周期结束

type Option

type Option struct{}

func (Option) Default

func (Option) Default() option.Setting[RPCOptions]

func (Option) Deliverers

func (Option) Deliverers(deliverers ...IDeliverer) option.Setting[RPCOptions]

func (Option) Dispatchers

func (Option) Dispatchers(dispatchers ...IDispatcher) option.Setting[RPCOptions]

type RPCOptions

type RPCOptions struct {
	Deliverers  []IDeliverer
	Dispatchers []IDispatcher
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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