Documentation ¶
Index ¶
- type IdField
- type JSONRPC2Error
- type JSONRPC2Field
- type JSONRPC2Node
- func (self *JSONRPC2Node) Close()
- func (self *JSONRPC2Node) DebugPrintfln(format string, data ...any)
- func (self *JSONRPC2Node) DebugPrintln(data ...any)
- func (self *JSONRPC2Node) GetDebugName() string
- func (self *JSONRPC2Node) PushMessageFromOutside(data []byte) (error, error)
- func (self *JSONRPC2Node) ResetResponseTimeout(id any, new_orig_timeout time.Duration) bool
- func (self *JSONRPC2Node) SendError(msg *Message) error
- func (self *JSONRPC2Node) SendMessage(msg *Message) error
- func (self *JSONRPC2Node) SendNotification(msg *Message) error
- func (self *JSONRPC2Node) SendRequest(msg *Message, genid bool, unhandled bool, rh *JSONRPC2NodeRespHandler, ...) (ret_any any, ret_err error)
- func (self *JSONRPC2Node) SendResponse(msg *Message) error
- func (self *JSONRPC2Node) SetDebug(val bool)
- func (self *JSONRPC2Node) SetDebugName(name string)
- type JSONRPC2NodeNewRequestIdHook
- type JSONRPC2NodeRespHandler
- type Message
- func (self *Message) DelId()
- func (self *Message) GetId() (any, bool)
- func (self *Message) HasErrorField() bool
- func (self *Message) HasId() bool
- func (self *Message) HasMethodField() bool
- func (self *Message) HasRequestFields() bool
- func (self *Message) HasResponseFields() bool
- func (self *Message) HasResultField() bool
- func (self *Message) IsError() bool
- func (self *Message) IsInvalid() bool
- func (self *Message) IsInvalidError() error
- func (self *Message) IsNotification() bool
- func (self *Message) IsRequestAndNotNotification() bool
- func (self *Message) IsRequestOrNotification() bool
- func (self *Message) IsResponseAndNotError() bool
- func (self *Message) IsResponseOrError() bool
- func (self *Message) SetId(val any) error
- func (val *Message) String() string
- type ProtocolErrorConst
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONRPC2Error ¶
type JSONRPC2Field ¶
type JSONRPC2Field struct {
JSONRPC string `json:"jsonrpc"`
}
type JSONRPC2Node ¶
type JSONRPC2Node struct { // the resulting errors are returned to PushMessageFromOutsied caller. // error #0 - if protocol error // error #1 - error preventing normal error response OnRequestCB func(msg *Message) (error, error) OnUnhandledResponseCB func(msg *Message) // JSONRPC2Node doesn't use error returned by this CB. error is simply // passed to SendMessage caller PushMessageToOutsideCB func(data []byte) error // contains filtered or unexported fields }
func NewJSONRPC2Node ¶
func NewJSONRPC2Node() *JSONRPC2Node
func (*JSONRPC2Node) Close ¶
func (self *JSONRPC2Node) Close()
func (*JSONRPC2Node) DebugPrintfln ¶
func (self *JSONRPC2Node) DebugPrintfln(format string, data ...any)
func (*JSONRPC2Node) DebugPrintln ¶
func (self *JSONRPC2Node) DebugPrintln(data ...any)
func (*JSONRPC2Node) GetDebugName ¶
func (self *JSONRPC2Node) GetDebugName() string
func (*JSONRPC2Node) PushMessageFromOutside ¶
func (self *JSONRPC2Node) PushMessageFromOutside(data []byte) (error, error)
push new message from outside into node returned values:
#0 protocol violation - not critical for server running, #1 error - should be treated as server errors
func (*JSONRPC2Node) ResetResponseTimeout ¶
func (self *JSONRPC2Node) ResetResponseTimeout( id any, new_orig_timeout time.Duration, ) bool
returns true on successful operation
func (*JSONRPC2Node) SendError ¶
func (self *JSONRPC2Node) SendError(msg *Message) error
func (*JSONRPC2Node) SendMessage ¶
func (self *JSONRPC2Node) SendMessage(msg *Message) error
send message without performing any protocol compliance checks. except: this function resets msg's jsonrpc field
func (*JSONRPC2Node) SendNotification ¶
func (self *JSONRPC2Node) SendNotification(msg *Message) error
func (*JSONRPC2Node) SendRequest ¶
func (self *JSONRPC2Node) SendRequest( msg *Message, genid bool, unhandled bool, rh *JSONRPC2NodeRespHandler, response_timeout time.Duration, request_id_hook *JSONRPC2NodeNewRequestIdHook, ) (ret_any any, ret_err error)
returns the final message id. this function can be used to automatically generate new Id for message and for defining a response handler for response (or errors). if request_id_hook is defined, it is to send id used in request being sent and waits for signal request_id_hook.Continue before actually perform sending use (pass obj created by you) rh param to be used for response handling
func (*JSONRPC2Node) SendResponse ¶
func (self *JSONRPC2Node) SendResponse(msg *Message) error
func (*JSONRPC2Node) SetDebug ¶
func (self *JSONRPC2Node) SetDebug(val bool)
func (*JSONRPC2Node) SetDebugName ¶
func (self *JSONRPC2Node) SetDebugName(name string)
type JSONRPC2NodeNewRequestIdHook ¶
type JSONRPC2NodeNewRequestIdHook struct { NewId chan<- any Continue <-chan struct{} }
type JSONRPC2NodeRespHandler ¶
type JSONRPC2NodeRespHandler struct { OnTimeout func() OnClose func() OnResponse func(message *Message) }
func NewChannelledJSONRPC2NodeRespHandler ¶
func NewChannelledJSONRPC2NodeRespHandler() ( timedout <-chan struct{}, closed <-chan struct{}, msg <-chan *Message, rh *JSONRPC2NodeRespHandler, )
type Message ¶
type Message struct { JSONRPC2Field IdField Request Response }
func NewRequestFromAny ¶
func NewRequestFromString ¶
func NewResponseFromAny ¶
func NewResponseFromString ¶
func (*Message) HasResponseFields ¶
self.HasResultField() || self.HasErrorField()
func (*Message) IsInvalidError ¶
message is invalid if:
- it has (or has not) both request and response fields
- has response fields, but has no ID
- has response fields, and has both result and error field
func (*Message) IsNotification ¶
func (*Message) IsRequestAndNotNotification ¶
func (*Message) IsRequestOrNotification ¶
func (*Message) IsResponseAndNotError ¶
func (*Message) IsResponseOrError ¶
type ProtocolErrorConst ¶
type ProtocolErrorConst int
const ( ProtocolErrorConstParseError ProtocolErrorConst = -32700 ProtocolErrorConstInvalidRequest ProtocolErrorConst = -32600 ProtocolErrorMethodNotFound ProtocolErrorConst = -32601 ProtocolErrorInvalidParams ProtocolErrorConst = -32602 ProtocolErrorInternalError ProtocolErrorConst = -32603 ProtocolErrorServerError_32000 ProtocolErrorConst = -32000 ProtocolErrorServerError_32099 ProtocolErrorConst = -32099 )
type Response ¶
type Response struct { Result any `json:"result,omitempty"` Error *JSONRPC2Error `json:"error,omitempty"` }