Documentation ¶
Index ¶
Constants ¶
const ( // DefaultErrorCode default error code DefaultErrorCode = -32000 // InvalidRequestErrorCode error code for invalid requests InvalidRequestErrorCode = -32600 // NotFoundErrorCode error code for not found objects NotFoundErrorCode = -32601 // InvalidParamsErrorCode error code for invalid parameters InvalidParamsErrorCode = -32602 // ParserErrorCode error code for parsing errors ParserErrorCode = -32700 )
Variables ¶
var ( // ErrBatchRequestsDisabled returned by the pool mananger server when a batch request is detected and the batch requests are disabled via configuration ErrBatchRequestsDisabled = fmt.Errorf("batch requests are disabled") // ErrBatchRequestsLimitExceeded returned by the server when a batch request is detected and the number of requests are greater than the configured limit ErrBatchRequestsLimitExceeded = fmt.Errorf("batch requests limit exceeded") )
Functions ¶
Types ¶
type ArgBytes ¶
type ArgBytes []byte
ArgBytes helps to marshal byte array values provided in the RPC requests
func ArgBytesPtr ¶
ArgBytesPtr helps to marshal byte array values provided in the RPC requests
type Config ¶
type Config struct { // Host defines the network adapter that will be used to serve the HTTP requests Host string `mapstructure:"Host"` // Port defines the port to serve the endpoints via HTTP Port int `mapstructure:"Port"` // ReadTimeout is the HTTP server read timeout. Check net/http.server.ReadTimeout and net/http.server.ReadHeaderTimeout ReadTimeout types.Duration `mapstructure:"ReadTimeout"` // WriteTimeout is the HTTP server write timeout. Check net/http.server.WriteTimeout WriteTimeout types.Duration `mapstructure:"WriteTimeout"` // MaxRequestsPerIPAndSecond defines how much requests a single IP can send within a single second MaxRequestsPerIPAndSecond float64 `mapstructure:"MaxRequestsPerIPAndSecond"` // EnableHttpLog allows the user to enable or disable the logs related to the HTTP requests to be captured by the server. EnableHttpLog bool `mapstructure:"EnableHttpLog"` // BatchRequestsEnabled defines if the batch requests are enabled or disabled BatchRequestsEnabled bool `mapstructure:"BatchRequestsEnabled"` // BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request BatchRequestsLimit uint `mapstructure:"BatchRequestsLimit"` }
Config for pool-manager JSON-RPC server
type Endpoints ¶
type Endpoints struct {
// contains filtered or unexported fields
}
Endpoints contains implementations for the pool-manager JSON-RPC endpoints
func NewEndpoints ¶
NewEndpoints creates an new instance of pool-manager JSON-RPC endpoints
type Error ¶
Error interface
func RPCErrorResponse ¶
RPCErrorResponse formats error to be returned through RPC
type ErrorObject ¶
type ErrorObject struct { Code int `json:"code"` Message string `json:"message"` Data *ArgBytes `json:"data,omitempty"` }
ErrorObject is a jsonrpc error
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler manage services to handle pool-manager RPC requests
type Request ¶
type Request struct { JSONRPC string `json:"jsonrpc"` ID interface{} `json:"id"` Method string `json:"method"` Params json.RawMessage `json:"params,omitempty"` }
Request is a jsonrpc Request
type Response ¶
type Response struct { JSONRPC string `json:"jsonrpc"` Id interface{} `json:"id"` Result json.RawMessage `json:"result,omitempty"` Error *ErrorObject `json:"error,omitempty"` }
Response is a jsonrpc success/error response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a JSON-RPC server to handle pool-manager requests
type ServerError ¶
type ServerError struct {
// contains filtered or unexported fields
}
ServerError represents an error returned by a pool manager endpoint
func NewServerError ¶
func NewServerError(code int, err string, args ...interface{}) *ServerError
NewServerError creates a new error instance to be returned by the pool manager endpoints
func NewServerErrorWithData ¶
func NewServerErrorWithData(code int, err string, data []byte, args ...interface{}) *ServerError
NewServerErrorWithData creates a new error instance with data to be returned by the pool manager endpoints
func (*ServerError) ErrorCode ¶
func (e *ServerError) ErrorCode() int
ErrorCode returns the error code
func (*ServerError) ErrorData ¶
func (e *ServerError) ErrorData() []byte
ErrorData returns the error data