Documentation ¶
Index ¶
- Constants
- func Request(ctx context.Context, methodName string, params ParamsDataMarshaller) (*structs.Request, error)
- func Response(ctx context.Context, id interface{}, data *json.RawMessage, ...) *structs.Response
- type ErrorMessages
- type InterceptorCallMethod
- type InterceptorCallMethods
- type JSONRPC
- func (j *JSONRPC) Error(ctx context.Context, err error, errorCode int, id interface{}) *structs.Response
- func (j *JSONRPC) HandleBatchRPC(ctx context.Context, data structs.Requests) structs.BatchFullResponse
- func (j *JSONRPC) HandleRPC(ctx context.Context, data *structs.Request) *structs.Response
- func (j *JSONRPC) HandleRPCJsonRawMessage(ctx context.Context, data json.RawMessage) json.RawMessage
- func (j *JSONRPC) RegisterError(code int, msg string) error
- func (j *JSONRPC) RegisterGlobalInterceptorCall(method InterceptorCallMethod)
- func (j *JSONRPC) RegisterMethod(name string, method RPCMethod) error
- func (j *JSONRPC) SetDefaultTimeOut(timeout int)
- type ParamsDataMarshaller
- type RPCMethod
- type RPCMethods
Constants ¶
const ( // ParseErrorCode : parse error. not well formed ParseErrorCode = -32700 // InvalidRequestErrorCode : Invalid Request InvalidRequestErrorCode = -32600 // MethodNotFoundErrorCode : requested method not found MethodNotFoundErrorCode = -32601 // InvalidParamsErrorCode : invalid method parameters InvalidParamsErrorCode = -32602 // InternalErrorCode : Internal error InternalErrorCode = -32603 // OK : everything is ok OK = 0 //MethodNotImplemented : use for develop method MethodNotImplemented = -32604 //RequestTimeLimit : tooooo long RequestTimeLimit = -32605 )
@see http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
const ( // Version const for define version of protocol // @see https://www.jsonrpc.org/specification#request_object Version = "2.0" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InterceptorCallMethod ¶
type InterceptorCallMethod func(ctx context.Context, methodName string, data json.RawMessage, id interface{}) (context.Context, int, error)
InterceptorCallMethod interface for interceptor method
type InterceptorCallMethods ¶
type InterceptorCallMethods []InterceptorCallMethod
InterceptorCallMethods registry for global interceptors
type JSONRPC ¶
type JSONRPC struct {
// contains filtered or unexported fields
}
JSONRPC container for jsonrpc
func (*JSONRPC) Error ¶
func (j *JSONRPC) Error( ctx context.Context, err error, errorCode int, id interface{}, ) *structs.Response
Error is method for create response with error code
func (*JSONRPC) HandleBatchRPC ¶
func (j *JSONRPC) HandleBatchRPC(ctx context.Context, data structs.Requests) structs.BatchFullResponse
HandleBatchRPC make batch rpc
func (*JSONRPC) HandleRPCJsonRawMessage ¶
func (j *JSONRPC) HandleRPCJsonRawMessage(ctx context.Context, data json.RawMessage) json.RawMessage
HandleRPCJsonRawMessage receive jsonRaw , parse, magic and send jsonRaw
func (*JSONRPC) RegisterError ¶
RegisterError register new error @see http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
func (*JSONRPC) RegisterGlobalInterceptorCall ¶
func (j *JSONRPC) RegisterGlobalInterceptorCall(method InterceptorCallMethod)
RegisterGlobalInterceptorCall register global interceptors
func (*JSONRPC) RegisterMethod ¶
RegisterMethod new method
func (*JSONRPC) SetDefaultTimeOut ¶
SetDefaultTimeOut set timeout for func run
type ParamsDataMarshaller ¶
ParamsDataMarshaller interface for Request params
type RPCMethod ¶
type RPCMethod func(ctx context.Context, data json.RawMessage) (json.RawMessage, int, error)
RPCMethod define function interface