Documentation
¶
Index ¶
- Variables
- func NewServer(opts ...*option_server) *server
- func OptionServer() *option_server
- func RegistCustomError(rt reflect.Type)
- func WriteFile(req *dto.FileBody) (err error)
- type Call
- type Client
- func (this *Client) Call(server string, moduleFunc string, req, ret any, opts ...*Option) error
- func (this *Client) Go(server string, moduleFunc string, req, ret any, opts ...*Option) *Call
- func (this *Client) Register(rcvr any) error
- func (this *Client) RegisterFunc(funcname string, function any) error
- func (this *Client) RegisterName(name string, rcvr any) error
- func (this *Client) Send(server, moduleFunc string, v any, opts ...*Option) error
- func (this *Client) SendFile(server string, moduleFunc string, save_path string, reader io.Reader, ...) (err error)
- type Option
- func (this *Option) Merge(opts ...*Option) *Option
- func (this *Option) RegistRetErr(r error) *Option
- func (this *Option) SetCheckInterval(t time.Duration) *Option
- func (this *Option) SetChunksMaxSize(t int) *Option
- func (this *Option) SetCoderT(t coder.T) *Option
- func (this *Option) SetCompressT(t compressor.T) *Option
- func (this *Option) SetHeartInterval(t time.Duration) *Option
- func (this *Option) SetMaxCacheSize(t int) *Option
- func (this *Option) SetMetaCoderT(t coder.T) *Option
- func (this *Option) SetMetaData(meta any) *Option
- func (this *Option) SetReadDeadline(t time.Duration) *Option
- func (this *Option) SetReqCoderT(t coder.T) *Option
- func (this *Option) SetResCoderT(t coder.T) *Option
- func (this *Option) SetSecret(s string) *Option
- func (this *Option) SetTimeout(t time.Duration) *Option
- func (this *Option) SetWeight(t int) *Option
- func (this *Option) SetWriteDeadline(t time.Duration) *Option
Constants ¶
This section is empty.
Variables ¶
View Source
var ( VerifyError = errors.New("Client VerifyError") ReadError = errors.New("Client ReadError") ServerReadError = errors.New("Server ReadError") UnzipError = errors.New("Client UnzipError") WriteError = errors.New("Client WriteError") ModuleFuncError = errors.New("Client ModuleFunc must like rpc.func") ServerError = errors.New("ServerError") FuncError = errors.New("FuncError") ReqTimeOutError = errors.New("ReqTimeoutError") ErrCoderRawBodyMustData = errors.New("CoderRawBodyMustData") ErrCusstomNoReceiveType = errors.New("ErrCusstomNoReceiveType") )
Functions ¶
func OptionServer ¶ added in v2.0.1
func OptionServer() *option_server
func RegistCustomError ¶ added in v2.0.5
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
1. service - func_module -> anonymity_func 1. service - module -> func
func (*Client) RegisterFunc ¶ added in v2.0.1
func (*Client) RegisterName ¶
func (p *Person) Func(meta int, req int) (res int, err error) func (p *Person) Func1(meta int, req int) (err error) func (p *Person) Func2(req int) (res int, err error) func (p *Person) Func3(req int) (err error)
支持以上4种结构
type Option ¶ added in v2.0.1
type Option struct {
Meta any //放在header中的透传信息
//client
MetaCoderT *coder.T //meta数据的编解码器
ReqCoderT *coder.T //请求数据的编解码器
ResCoderT *coder.T //响应数据的编解码器,还是自定义错误的解码器,之所以请求与返回需要不同的编解码,是有文件上传的场景,上传有个自定义的编码方式
CompressT *compressor.T //压缩数据的编解码器
Timeout *time.Duration //这个发送的超时时间,版本1是中心超市,现在做客户端超时
CheckInterval *time.Duration //检测是否连接的间隔
HeartInterval *time.Duration //心跳间隔,负数默认不开启心跳检测
ChunksSize *int //发送文件时,每次分片文件大小
RetErr error //返回一个自定义的错误
Weight *int //权重 ,负数不参只保留一个链接,且绝对值越大,权重越大
ReadDeadline *time.Duration
WriteDeadline *time.Duration
MaxCacheSize *int //sendchan 的容量
//server
Secret *string
}
func (*Option) RegistRetErr ¶ added in v2.0.2
func (*Option) SetCheckInterval ¶ added in v2.0.2
func (*Option) SetChunksMaxSize ¶ added in v2.0.2
func (*Option) SetCompressT ¶ added in v2.0.2
func (this *Option) SetCompressT(t compressor.T) *Option
func (*Option) SetHeartInterval ¶ added in v2.0.2
< 0 将没有心跳
func (*Option) SetMaxCacheSize ¶ added in v2.0.9
func (*Option) SetMetaData ¶ added in v2.0.2
func (*Option) SetReadDeadline ¶ added in v2.0.9
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gencrpc
command
|
|
|
copy
|
copy |
|
目前这个性能最好,不在乎其内部结构是否缺少 msgp 是msgpack的代码生成实现 vmihailenco/msgpack 是msgpack的非代码实现,这2个玩意儿是大体兼容的,在一些特殊处理下还是有区别:var a []string = nil,就无法混用 大体上,之前遇到的不兼容的地方,都是编码使用msgpack,解码又用的是msgp
|
目前这个性能最好,不在乎其内部结构是否缺少 msgp 是msgpack的代码生成实现 vmihailenco/msgpack 是msgpack的非代码实现,这2个玩意儿是大体兼容的,在一些特殊处理下还是有区别:var a []string = nil,就无法混用 大体上,之前遇到的不兼容的地方,都是编码使用msgpack,解码又用的是msgp |
Click to show internal directories.
Click to hide internal directories.