rpctypes

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SocketType

func SocketType(listenAddr string) string

---------------------------------------- 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 added in v0.14.0

type EventSubscriber interface {
	Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, out chan<- interface{}) error
	Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error
	UnsubscribeAll(ctx context.Context, subscriber string) error
}

EventSubscriber mirros tendermint/tendermint/types.EventBusSubscriber

type RPCError added in v0.11.0

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data,omitempty"`
}

func (RPCError) Error added in v0.12.0

func (err RPCError) Error() string

type RPCRequest

type RPCRequest struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      string          `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"` // must be map[string]interface{} or []interface{}
}

func ArrayToRequest

func ArrayToRequest(id string, method string, params []interface{}) (RPCRequest, error)

func MapToRequest

func MapToRequest(id string, method string, params map[string]interface{}) (RPCRequest, error)

func NewRPCRequest

func NewRPCRequest(id string, method string, params json.RawMessage) RPCRequest

func (RPCRequest) String added in v0.10.4

func (req RPCRequest) String() string

type RPCResponse

type RPCResponse struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      string          `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *RPCError       `json:"error,omitempty"`
}

func NewRPCErrorResponse added in v0.11.0

func NewRPCErrorResponse(id string, code int, msg string, data string) RPCResponse

func NewRPCSuccessResponse added in v0.11.0

func NewRPCSuccessResponse(id string, res interface{}) RPCResponse

func RPCInternalError added in v0.11.0

func RPCInternalError(id string, err error) RPCResponse

func RPCInvalidParamsError added in v0.11.0

func RPCInvalidParamsError(id string, err error) RPCResponse

func RPCInvalidRequestError added in v0.11.0

func RPCInvalidRequestError(id string, err error) RPCResponse

func RPCMethodNotFoundError added in v0.11.0

func RPCMethodNotFoundError(id string) RPCResponse

func RPCParseError added in v0.11.0

func RPCParseError(id string, err error) RPCResponse

func RPCServerError added in v0.11.0

func RPCServerError(id string, err error) RPCResponse

func (RPCResponse) String added in v0.10.4

func (resp RPCResponse) String() string

type WSRPCConnection

type WSRPCConnection interface {
	GetRemoteAddr() string
	WriteRPCResponse(resp RPCResponse)
	TryWriteRPCResponse(resp RPCResponse) bool
	GetEventSubscriber() EventSubscriber
}

*wsConnection implements this interface.

type WSRPCContext

type WSRPCContext struct {
	Request RPCRequest
	WSRPCConnection
}

websocket-only RPCFuncs take this as the first parameter.

Jump to

Keyboard shortcuts

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