Documentation
¶
Overview ¶
Package rpcx
@author: xwc1125
Package rpcx ¶
@author: xwc1125
Package rpcx ¶
@author: xwc1125
Index ¶
- Variables
- type API
- type Error
- type Header
- type JsonError
- type JsonResponse
- type Method
- type Namespace
- type RPC
- type RPCX
- func (r *RPCX) Exec(ctx context.Context, namespace string, method string, reqId interface{}, ...) *JsonResponse
- func (r *RPCX) Namespaces(ctx context.Context) []*Namespace
- func (r *RPCX) Namespaces2(ctx context.Context) map[string]map[string]*Method
- func (r *RPCX) Register(namespace string, rcvr interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( JsonRpcVersion = "2.0" ServiceMethodSeparator = "." Debug = false )
Functions ¶
This section is empty.
Types ¶
type JsonError ¶
type JsonResponse ¶
type JsonResponse struct {
Version string `json:"jsonrpc,omitempty"`
Id interface{} `json:"id,omitempty"`
Result interface{} `json:"result,omitempty"`
Error error `json:"error,omitempty"`
}
func (JsonResponse) MarshalJSON ¶
func (j JsonResponse) MarshalJSON() ([]byte, error)
func (JsonResponse) String ¶
func (j JsonResponse) String() string
type RPC ¶
type RPC interface {
// Register 注册命名及其类方法[对外暴露的方法必须是首字母大写]
// namespace 命名空间
// rcvr 服务对象(函数类)
Register(namespace string, rcvr interface{}) error
// Exec 执行
// namespace 命名空间
// method 方法名称
// reqId 请求的ID
// params 请求的参数
Exec(ctx context.Context, namespace string, method string, reqId interface{}, params ...interface{}) *JsonResponse
Namespaces(ctx context.Context) []*Namespace
Namespaces2(ctx context.Context) map[string]map[string]*Method
}
RPC rpc 的接口
Click to show internal directories.
Click to hide internal directories.