proxy

package
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RpcSyncCallType  = iota + 1 // 同步请求
	RpcAsyncCallType            // 异步请求
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncCallOption added in v0.5.7

type AsyncCallOption func(call *RpcAsyncCall)

func WithCallBack added in v0.5.7

func WithCallBack(callBack RpcCallBack) AsyncCallOption

type BaseRpcCall added in v0.5.7

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

BaseRpcCall rpc call的公共数据

func (*BaseRpcCall) DecRetryTimes added in v0.5.7

func (c *BaseRpcCall) DecRetryTimes() int32

func (*BaseRpcCall) GetCallData added in v0.5.7

func (c *BaseRpcCall) GetCallData() []byte

func (*BaseRpcCall) GetCallId added in v0.5.7

func (c *BaseRpcCall) GetCallId() uint32

func (*BaseRpcCall) GetErrorCode added in v0.5.7

func (c *BaseRpcCall) GetErrorCode() uint32

func (*BaseRpcCall) GetMethodIndex added in v0.5.7

func (c *BaseRpcCall) GetMethodIndex() uint32

func (*BaseRpcCall) GetProxyId added in v0.5.7

func (c *BaseRpcCall) GetProxyId() ProxyUuid

func (*BaseRpcCall) GetRetryTimes added in v0.5.7

func (c *BaseRpcCall) GetRetryTimes() int32

func (*BaseRpcCall) GetTimeout added in v0.5.7

func (c *BaseRpcCall) GetTimeout() uint32

func (*BaseRpcCall) SetErrorCode added in v0.5.7

func (c *BaseRpcCall) SetErrorCode(errorCode uint32)

type IRpcCall added in v0.5.7

type IRpcCall interface {
	// GetCallId 获取RPC调用ID
	GetCallId() uint32
	// GetErrorCode 获取RPC错误码
	GetErrorCode() uint32
	// GetProxyId 获取RPC调用的proxy实例id
	GetProxyId() ProxyUuid
	// SetErrorCode 设置RPC调用错误码
	SetErrorCode(uint32)
	// DecRetryTimes 减少失败后重试次数
	DecRetryTimes() int32
	// GetRetryTimes 获取失败后重试次数
	GetRetryTimes() int32
	// GetTimeout 获取超时时间
	GetTimeout() uint32
	// GetMethodIndex 获取当前调用的方法序号
	GetMethodIndex() uint32
	// GetCallData 获取RPC调用数据
	GetCallData() []byte
	// DoRet 通知RPC Call 返回
	DoRet([]byte)
	// Done rpc 调用返回值, oneway 会直接返回nil, 异步调用在返回后才会赋值,否则是nil, 同步调用回阻塞, 直到超时
	Done() ([]byte, uint32)
}

IRpcCall rpc call 接口,这里派生出了 sync call 与 async call

type ProxyUuid

type ProxyUuid uint32

type RpcAsyncCall added in v0.5.7

type RpcAsyncCall struct {
	*BaseRpcCall // 基类数据
	// contains filtered or unexported fields
}

RpcAsyncCall rpc 异步调用请求

func NewAsyncCall added in v0.5.7

func NewAsyncCall(opts ...RpcCallOption) *RpcAsyncCall

func (*RpcAsyncCall) ApplyOptions added in v0.5.7

func (r *RpcAsyncCall) ApplyOptions(opts ...AsyncCallOption)

func (*RpcAsyncCall) DoRet added in v0.5.7

func (r *RpcAsyncCall) DoRet(bytes []byte)

func (*RpcAsyncCall) Done added in v0.5.7

func (r *RpcAsyncCall) Done() ([]byte, uint32)

type RpcCallBack added in v0.5.7

type RpcCallBack func([]byte, uint32)

RpcCallBack rpc 回调函数 interface 为返回值, uint32 为错误码

type RpcCallOption added in v0.5.7

type RpcCallOption func(call *BaseRpcCall)

RpcCallOption rpc 调用参数设置

func WithCallId added in v0.5.7

func WithCallId(callId uint32) RpcCallOption

WithCallId 设置rpc call id,用于记录rpc call

func WithCallType added in v0.5.7

func WithCallType(callType int) RpcCallOption

func WithErrorCode added in v0.5.7

func WithErrorCode(errorCode uint32) RpcCallOption

WithErrorCode 设置错误码

func WithMethodIndex added in v0.5.7

func WithMethodIndex(methodIndex uint32) RpcCallOption

WithMethodIndex 设置rpc 调用的方法编号

func WithProxyId added in v0.5.7

func WithProxyId(proxyId ProxyUuid) RpcCallOption

WithProxyId 设置发起rpc call 的proxy的实列id

func WithRetryTimes added in v0.5.7

func WithRetryTimes(retryTimes int32) RpcCallOption

WithRetryTimes 设置rpc call 允许的重试次数

func WithRpcMsg added in v0.5.7

func WithRpcMsg(rpcMsg []byte) RpcCallOption

WithRpcMsg 设置rpc 请求包体,用于在请求失败后重试

func WithTimeout added in v0.5.7

func WithTimeout(timeout uint32) RpcCallOption

WithTimeout 设置rpc 调用超时时间

type RpcSyncCall added in v0.5.7

type RpcSyncCall struct {
	*BaseRpcCall // 基类数据
	// contains filtered or unexported fields
}

RpcSyncCall rpc 同步调用请求

func NewSyncCall added in v0.5.7

func NewSyncCall(opts ...RpcCallOption) *RpcSyncCall

func (*RpcSyncCall) DoRet added in v0.5.7

func (r *RpcSyncCall) DoRet(response []byte)

func (*RpcSyncCall) Done added in v0.5.7

func (r *RpcSyncCall) Done() ([]byte, uint32)

Jump to

Keyboard shortcuts

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