Documentation ¶
Index ¶
- Constants
- func MarshalJSONRpcRequest(id int64, method string, params ...interface{}) (data []byte, err error)
- type HttpClient
- type HttpOption
- type JSONRpcError
- type JSONRpcRequest
- type JSONRpcResponse
- type MergeClient
- type MergeServer
- type Option
- type RelayClient
- func (c *RelayClient) Call(request []byte) (response []byte, err error)
- func (c *RelayClient) CallNoReply(request []byte) (err error)
- func (c *RelayClient) Close()
- func (c *RelayClient) GetConnCount() int
- func (c *RelayClient) Subscribe(ctx context.Context, request []byte, cb func(context.Context, []byte) bool, ...) (err error)
- type RelayConn
- type RelayOption
- type SubFunc
- type SubNotify
- type SubscribeOption
- type WebSocketClient
- func (c *WebSocketClient) Call(out interface{}, method string, params ...interface{}) (err error)
- func (c *WebSocketClient) CallNoReply(method string, params ...interface{}) (err error)
- func (c *WebSocketClient) Close()
- func (c *WebSocketClient) Send(request []byte) (err error)
- func (c *WebSocketClient) Subscribe(ctx context.Context, request []byte, ...) (err error)
- func (c *WebSocketClient) SubscribeCall(ctx context.Context, cb func(ctx context.Context, msg []byte) bool, ...) (err error)
Constants ¶
const ( UrlSchemeWS = "ws" UrlSchemeWSS = "wss" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HttpClient ¶ added in v0.2.0
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶ added in v0.2.0
func NewHttpClient(strUrl string, header http.Header, opts ...*HttpOption) (*HttpClient, error)
func (*HttpClient) Call ¶ added in v0.2.0
func (c *HttpClient) Call(out interface{}, method string, params ...interface{}) (err error)
POST request to http server
type HttpOption ¶ added in v0.2.0
type HttpOption struct {
Timeout int
}
type JSONRpcError ¶ added in v0.2.3
type JSONRpcRequest ¶ added in v0.2.0
type JSONRpcRequest struct { Id int64 `json:"id"` Jsonrpc string `json:"jsonrpc"` Method string `json:"method"` Params interface{} `json:"params"` }
func MakeJSONRpcRequest ¶ added in v0.2.0
func MakeJSONRpcRequest(id int64, method string, params ...interface{}) *JSONRpcRequest
func (*JSONRpcRequest) Marshal ¶ added in v0.2.0
func (m *JSONRpcRequest) Marshal() ([]byte, error)
type JSONRpcResponse ¶ added in v0.2.0
type JSONRpcResponse struct { Id int `json:"id"` Jsonrpc string `json:"jsonrpc"` Error *JSONRpcError `json:"error"` Result interface{} `json:"result"` }
func (*JSONRpcResponse) Unmarshal ¶ added in v0.2.0
func (m *JSONRpcResponse) Unmarshal(data []byte, v interface{}) error
type MergeClient ¶ added in v0.2.0
type MergeClient struct {
// contains filtered or unexported fields
}
func NewMergeClient ¶ added in v0.2.0
func (*MergeClient) Close ¶ added in v0.2.0
func (m *MergeClient) Close()
type MergeServer ¶ added in v0.2.0
type MergeServer struct {
// contains filtered or unexported fields
}
func NewMergeServer ¶ added in v0.2.0
func NewMergeServer(strNamespace string, handler interface{}, options ...*Option) *MergeServer
func (*MergeServer) AliasMethod ¶ added in v0.2.0
func (m *MergeServer) AliasMethod(alias, original string)
AliasMethod alias method to new name
func (*MergeServer) ListenAndServe ¶ added in v0.2.0
func (m *MergeServer) ListenAndServe(strUrl string) (err error)
ListenAndServe start a http server (NOTE: routine will be blocked)
func (*MergeServer) ServeHTTP ¶ added in v0.2.0
func (m *MergeServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP http handler
type RelayClient ¶
type RelayClient struct {
// contains filtered or unexported fields
}
func NewRelayClient ¶
func NewRelayClient(strUrl string, header http.Header, options ...*RelayOption) (*RelayClient, error)
func (*RelayClient) Call ¶
func (c *RelayClient) Call(request []byte) (response []byte, err error)
Call only relay a JSON-RPC request to remote server
func (*RelayClient) CallNoReply ¶ added in v0.2.4
func (c *RelayClient) CallNoReply(request []byte) (err error)
CallNoReply send a JSON-RPC request to remote server and return immediately
func (*RelayClient) Close ¶
func (c *RelayClient) Close()
func (*RelayClient) GetConnCount ¶ added in v0.7.0
func (c *RelayClient) GetConnCount() int
func (*RelayClient) Subscribe ¶ added in v0.1.3
func (c *RelayClient) Subscribe(ctx context.Context, request []byte, cb func(context.Context, []byte) bool, options ...*SubscribeOption) (err error)
Subscribe send a JSON-RPC request to remote server and subscribe this channel (if request is nil, just subscribe)
type RelayConn ¶ added in v0.4.0
type RelayConn struct {
// contains filtered or unexported fields
}
func (*RelayConn) ReadMessage ¶ added in v0.4.0
type RelayOption ¶
type SubNotify ¶ added in v0.4.0
type SubNotify struct {
// contains filtered or unexported fields
}
type SubscribeOption ¶ added in v0.5.0
type SubscribeOption struct {
Block bool //blocking subscribe channel
}
type WebSocketClient ¶ added in v0.2.0
type WebSocketClient struct {
// contains filtered or unexported fields
}
func NewWebSocketClient ¶ added in v0.2.0
func NewWebSocketClient(strUrl string, header http.Header) (*WebSocketClient, error)
func (*WebSocketClient) Call ¶ added in v0.2.0
func (c *WebSocketClient) Call(out interface{}, method string, params ...interface{}) (err error)
Call submit a JSON-RPC request to remote server
func (*WebSocketClient) CallNoReply ¶ added in v0.2.4
func (c *WebSocketClient) CallNoReply(method string, params ...interface{}) (err error)
CallNoReply send a JSON-RPC request to remote server and return immediately
func (*WebSocketClient) Close ¶ added in v0.2.0
func (c *WebSocketClient) Close()
func (*WebSocketClient) Send ¶ added in v0.2.0
func (c *WebSocketClient) Send(request []byte) (err error)
Send send a request to remote server and return immediately
func (*WebSocketClient) Subscribe ¶ added in v0.2.0
func (c *WebSocketClient) Subscribe(ctx context.Context, request []byte, cb func(c context.Context, msg []byte) bool) (err error)
Subscribe send a request to remote server and subscribe this channel (if request is nil, just subscribe)
func (*WebSocketClient) SubscribeCall ¶ added in v0.2.4
func (c *WebSocketClient) SubscribeCall(ctx context.Context, cb func(ctx context.Context, msg []byte) bool, method string, params ...interface{}) (err error)
SubscribeCall send a JSON-RPC request to remote server and subscribe this channel (if method is nil, just subscribe)