Documentation ¶
Index ¶
- func SocketType(listenAddr string) string
- type EventSubscriber
- type RPCError
- type RPCRequest
- func ArrayToRequest(cdc *amino.Codec, id interface{}, method string, params []interface{}) (RPCRequest, error)
- func MapToRequest(cdc *amino.Codec, id interface{}, method string, params map[string]interface{}) (RPCRequest, error)
- func NewRPCRequest(id interface{}, method string, params json.RawMessage) RPCRequest
- type RPCResponse
- func NewJsonEventNotifyResponse(subscriptionID string, result interface{}) (RPCResponse, error)
- func NewRPCErrorResponse(id interface{}, code int, msg string, data string) RPCResponse
- func NewRPCSuccessResponse(cdc *amino.Codec, id interface{}, res interface{}) RPCResponse
- func RPCInternalError(id interface{}, err error) RPCResponse
- func RPCInvalidParamsError(id interface{}, err error) RPCResponse
- func RPCInvalidRequestError(id interface{}, err error) RPCResponse
- func RPCMethodNotFoundError(id interface{}) RPCResponse
- func RPCParseError(id interface{}, err error) RPCResponse
- func RPCServerError(id interface{}, err error) RPCResponse
- type Subscription
- type WSRPCConnection
- type WSRPCContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SocketType ¶
---------------------------------------- SOCKETS
Determine if its a unix or tcp socket. If tcp, must specify the port; `0.0.0.0` will return incorrectly as "unix" since there's no port TODO: deprecate
Types ¶
type EventSubscriber ¶
type EventSubscriber interface { // Subscribe subscribe event Subscribe(eventTypes ...types.EventType) (*Subscription, error) // Unsubscribe unsubscribe by subscribe id Unsubscribe(id string) error // Unsubscribe unsubscribe all event UnsubscribeAll() error }
EventSubscriber mirros DSiSc/apigateway/types.EventBusSubscriber
type RPCError ¶
type RPCRequest ¶
type RPCRequest struct { JSONRPC string `json:"jsonrpc"` ID interface{} `json:"id"` Method string `json:"method"` Params json.RawMessage `json:"params"` // must be map[string]interface{} or []interface{} }
func ArrayToRequest ¶
func ArrayToRequest(cdc *amino.Codec, id interface{}, method string, params []interface{}) (RPCRequest, error)
func MapToRequest ¶
func MapToRequest(cdc *amino.Codec, id interface{}, method string, params map[string]interface{}) (RPCRequest, error)
func NewRPCRequest ¶
func NewRPCRequest(id interface{}, method string, params json.RawMessage) RPCRequest
func (RPCRequest) String ¶
func (req RPCRequest) String() string
type RPCResponse ¶
type RPCResponse struct { JSONRPC string `json:"jsonrpc"` ID interface{} `json:"id,omitempty"` Result json.RawMessage `json:"result,omitempty"` Error *RPCError `json:"error,omitempty"` Method string `json:"method,omitempty"` Params json.RawMessage `json:"params,omitempty"` }
func NewJsonEventNotifyResponse ¶ added in v1.0.0
func NewJsonEventNotifyResponse(subscriptionID string, result interface{}) (RPCResponse, error)
func NewRPCErrorResponse ¶
func NewRPCErrorResponse(id interface{}, code int, msg string, data string) RPCResponse
func NewRPCSuccessResponse ¶
func NewRPCSuccessResponse(cdc *amino.Codec, id interface{}, res interface{}) RPCResponse
func RPCInternalError ¶
func RPCInternalError(id interface{}, err error) RPCResponse
func RPCInvalidParamsError ¶
func RPCInvalidParamsError(id interface{}, err error) RPCResponse
func RPCInvalidRequestError ¶
func RPCInvalidRequestError(id interface{}, err error) RPCResponse
func RPCMethodNotFoundError ¶
func RPCMethodNotFoundError(id interface{}) RPCResponse
func RPCParseError ¶
func RPCParseError(id interface{}, err error) RPCResponse
func RPCServerError ¶
func RPCServerError(id interface{}, err error) RPCResponse
func (RPCResponse) String ¶
func (resp RPCResponse) String() string
type Subscription ¶ added in v1.0.0
type Subscription struct { ID string // contains filtered or unexported fields }
Subscription is created when the client registers itself for a particular event.
func NewSubscription ¶ added in v1.0.0
func NewSubscription(ID string, eventChan chan interface{}, subscribers map[types.EventType]types.Subscriber) *Subscription
func (*Subscription) EventChan ¶ added in v1.0.0
func (sub *Subscription) EventChan() chan interface{}
func (*Subscription) QuitChan ¶ added in v1.0.0
func (sub *Subscription) QuitChan() chan interface{}
func (*Subscription) Stop ¶ added in v1.0.0
func (sub *Subscription) Stop()
func (*Subscription) Subscribers ¶ added in v1.0.0
func (sub *Subscription) Subscribers() map[types.EventType]types.Subscriber
type WSRPCConnection ¶
type WSRPCConnection interface { GetRemoteAddr() string WriteRPCResponse(resp RPCResponse) TryWriteRPCResponse(resp RPCResponse) bool GetEventSubscriber() EventSubscriber Codec() *amino.Codec }
*wsConnection implements this interface.
type WSRPCContext ¶
type WSRPCContext struct { Request RPCRequest WSRPCConnection }
websocket-only RPCFuncs take this as the first parameter.
Click to show internal directories.
Click to hide internal directories.