Documentation ¶
Index ¶
- Variables
- func ConnClosed(conn *net.Conn) bool
- type Client
- type Conn
- type ConnectionPool
- type RPCError
- type Request
- type Response
- func (r *Response) Err() error
- func (r *Response) GetBigFloat() (big.Float, error)
- func (r *Response) GetFloat64() (float64, error)
- func (r *Response) GetInt64() (int64, error)
- func (r *Response) GetNumber() (json.Number, error)
- func (r *Response) GetObject(obj interface{}) error
- func (r *Response) GetString() (string, error)
- func (r *Response) RawResult() []byte
- type TCPClient
- func (c TCPClient) Address() string
- func (c *TCPClient) Call(request *Request) (*Response, error)
- func (c *TCPClient) CallBatch(requests ...*Request) ([]*Response, error)
- func (c *TCPClient) CallBatchContext(ctx context.Context, requests ...*Request) ([]*Response, error)
- func (c *TCPClient) CallContext(ctx context.Context, request *Request) (*Response, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ParserError = RPCError{Code: -32700, Message: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."} InvalidRequest = RPCError{Code: -32600, Message: "The JSON sent is not a valid Request object."} MethodNotFound = RPCError{Code: -32601, Message: "The method does not exist / is not available."} InvalidParams = RPCError{Code: -32602, Message: "Invalid method parameter(s)."} InternalError = RPCError{Code: -32603, Message: "Internal JSON-RPC error."} ServerError = RPCError{Code: -32000, Message: "Reserved for implementation-defined server-errors."} )
Functions ¶
func ConnClosed ¶
Types ¶
type ConnectionPool ¶
type ConnectionPool struct { New func() (*net.Conn, error) // contains filtered or unexported fields }
func NewConnPool ¶
func NewConnPool(newFunc func() (*net.Conn, error)) *ConnectionPool
func (*ConnectionPool) Get ¶
func (p *ConnectionPool) Get() *net.Conn
func (*ConnectionPool) Init ¶
func (p *ConnectionPool) Init(n int) (int, []error)
creat N connection in pool
func (*ConnectionPool) Len ¶
func (p *ConnectionPool) Len() int
func (*ConnectionPool) Put ¶
func (p *ConnectionPool) Put(conn *net.Conn)
type RPCError ¶
type RPCError struct { Code int64 `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
func (RPCError) IsRpcError ¶
type Request ¶
type Request struct { Method string `json:"method"` Params interface{} `json:"params"` // contains filtered or unexported fields }
func NewRequest ¶
func (Request) MarshalJSON ¶
type Response ¶
type Response struct { Version string `json:"jsonrpc,omitempty"` Result json.RawMessage `json:"result,omitempty"` Error *RPCError `json:"error,omitempty"` Id int64 `json:"id,omitempty"` }
func (*Response) GetFloat64 ¶
type TCPClient ¶
type TCPClient struct {
// contains filtered or unexported fields
}
func NewTCPClient ¶
func (*TCPClient) CallBatchContext ¶
Click to show internal directories.
Click to hide internal directories.