package
0.0.0-20190318102628-d7df357d3e99
Repository: https://github.com/go-zh/tools.git
Documentation: pkg.go.dev
# Functions
Log is an implementation of Logger that outputs using log.Print It is not used by default, but is provided for easy logging in users code.
NewConn creates a new connection object that reads and writes messages from the supplied stream and dispatches incoming messages to the supplied handler.
NewErrorf builds a Error struct for the suppied message and code.
NewHeaderStream returns a Stream built on top of an io.Reader and io.Writer The messages are sent with HTTP content length and MIME type headers.
NewStream returns a Stream built on top of an io.Reader and io.Writer The messages are sent with no wrapping, and rely on json decode consistency to determine message boundaries.
# Constants
CodeInternalError is not currently returned but defined for completeness.
CodeInvalidParams should be returned by the handler when method parameter(s) were invalid.
CodeInvalidRequest is used when the JSON sent is not a valid Request object.
CodeMethodNotFound should be returned by the handler when the method does not exist / is not available.
CodeParseError is used when invalid JSON was received by the server.
CodeUnknownError should be used for all non coded errors.
Receive indicates the message is incoming.
Send indicates the message is outgoing.
# Structs
Conn is a JSON RPC 2 client server connection.
Error represents a structured error in a Response.
ID is a Request identifier.
Request is sent to a server to represent a Call or Notify operaton.
Response is a reply to a Request.
VersionTag is a special 0 sized struct that encodes as the jsonrpc version tag.
# Interfaces
Stream abstracts the transport mechanics from the JSON RPC protocol.
# Type aliases
Canceler is an option you can pass to NewConn which is invoked for cancelled outgoing requests.
Direction is used to indicate to a logger whether the logged message was being sent or received.
Handler is an option you can pass to NewConn to handle incoming requests.
Logger is an option you can pass to NewConn which is invoked for all messages flowing through a Conn.