Categorygithub.com/replit/jsonrpc2
modulepackage
0.1.2
Repository: https://github.com/replit/jsonrpc2.git
Documentation: pkg.go.dev

# README

jsonrpc2: JSON-RPC 2.0 implementation for Go Build Status Sourcegraph GoDoc

Package jsonrpc2 provides a Go implementation of JSON-RPC 2.0.

This package is experimental until further notice.

Open the code in Sourcegraph

Known issues

  • Batch requests and responses are not yet supported.

# Packages

Package websocket provides WebSocket transport support for JSON-RPC 2.0.

# Functions

AsyncHandler wraps a Handler such that each request is handled in its own goroutine.
ExtraField returns a call option which attaches the given name/value pair to the JSON-RPC 2.0 request.
HandlerWithError implements Handler by calling the func for each request and handling returned errors and results.
LogMessages causes all messages sent and received on conn to be logged using the provided logger.
Meta returns a call option which attaches the given meta object to the JSON-RPC 2.0 request (this is a Sourcegraph extension to JSON RPC 2.0 for carrying metadata).
NewBufferedStream creates a buffered stream from a network connection (or other similar interface).
NewConn creates a new JSON-RPC client/server connection using the given ReadWriteCloser (typically a TCP connection or stdio).
OnRecv causes all requests received on conn to invoke f(req, nil) and all responses to invoke f(req, resp),.
OnSend causes all requests sent on conn to invoke f(req, nil) and all responses to invoke f(nil, resp),.
PickID returns a call option which sets the ID on a request.
StringID returns a call option that instructs the request ID to be set as a string.

# Constants

Errors defined in the JSON-RPC spec.
Errors defined in the JSON-RPC spec.
Errors defined in the JSON-RPC spec.
Errors defined in the JSON-RPC spec.
Errors defined in the JSON-RPC spec.

# Variables

ErrClosed indicates that the JSON-RPC connection is closed (or in the process of closing).

# Structs

Conn is a JSON-RPC client/server connection.
Error represents a JSON-RPC response error.
HandlerWithErrorConfigurer is a handler created by HandlerWithError.
ID represents a JSON-RPC 2.0 request ID, which may be either a string or number (or null, which is unsupported).
PlainObjectCodec reads/writes plain JSON-RPC 2.0 objects without a header.
Request represents a JSON-RPC request or notification.
RequestField is a top-level field that can be added to the JSON-RPC request.
Response represents a JSON-RPC response.
VarintObjectCodec reads/writes JSON-RPC 2.0 objects with a varint header that encodes the byte length.
VSCodeObjectCodec reads/writes JSON-RPC 2.0 objects with Content-Length and Content-Type headers, as specified by https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#base-protocol.
Waiter proxies an ongoing JSON-RPC call.

# Interfaces

CallOption is an option that can be provided to (*Conn).Call to configure custom behavior.
Handler handles JSON-RPC requests and notifications.
JSONRPC2 describes an interface for issuing requests that speak the JSON-RPC 2 protocol.
Logger interface implements one method - Printf.
An ObjectCodec specifies how to encode and decode a JSON-RPC 2.0 object in a stream.
An ObjectStream is a bidirectional stream of JSON-RPC 2.0 objects.

# Type aliases

ConnOpt is the type of function that can be passed to NewConn to customize the Conn before it is created.