Versions in this module Expand all Collapse all v0 v0.2.0 Jul 16, 2026 Changes in this version type ProcessOption + func WithExtraEnv(kv ...string) ProcessOption v0.1.0 Jul 3, 2026 Changes in this version + const CodeInternalError + const CodeInvalidParams + const CodeInvalidRequest + const CodeMethodNotFound + const CodeParseError + const CodeServerError + const Version + var ErrClosed = errors.New("jsonrpc: transport closed") + func IsNotification(ctx context.Context) bool + func Unmarshal(params json.RawMessage, v any) error + type BatchCall struct + Method string + Out any + Params any + type BatchResult struct + Err error + Result json.RawMessage + type Client struct + func NewClient(t Transport) *Client + func (c *Client) Call(ctx context.Context, method string, params, out any) error + func (c *Client) CallBatch(ctx context.Context, calls []BatchCall) []BatchResult + func (c *Client) Close() error + func (c *Client) Notify(ctx context.Context, method string, params any) error + type Error struct + Code int + Data any + Message string + func Errorf(code int, format string, args ...any) *Error + func InternalError(message string) *Error + func InvalidParams(message string) *Error + func InvalidRequest(message string) *Error + func MethodNotFound(message string) *Error + func NewError(code int, message string, data any) *Error + func ParseError(message string) *Error + func ServerError(message string) *Error + func (e *Error) Error() string + type HTTPOption func(*HTTPTransport) + func WithHTTPClient(client *http.Client) HTTPOption + func WithHeader(key, value string) HTTPOption + type HTTPTransport struct + func NewHTTPTransport(url string, opts ...HTTPOption) *HTTPTransport + func (t *HTTPTransport) Call(ctx context.Context, req *Request) (*Response, error) + func (t *HTTPTransport) CallBatch(ctx context.Context, reqs []*Request) ([]*Response, error) + func (t *HTTPTransport) Close() error + func (t *HTTPTransport) Notify(ctx context.Context, req *Request) error + type Handler func(ctx context.Context, params json.RawMessage) (any, error) + func Typed[T any](fn func(ctx context.Context, params T) (any, error)) Handler + type Option func(*Server) + func WithErrorHandler(fn func(method string, err error)) Option + func WithSerialDispatch() Option + type Peer struct + func NewPeer(in io.Reader, out io.Writer, server *Server, opts ...PeerOption) *Peer + func NewProcessPeer(name string, args []string, server *Server, opts ...ProcessOption) (*Peer, error) + func (p *Peer) Call(ctx context.Context, req *Request) (*Response, error) + func (p *Peer) CallBatch(ctx context.Context, reqs []*Request) ([]*Response, error) + func (p *Peer) Client() *Client + func (p *Peer) Close() error + func (p *Peer) Done() <-chan struct{} + func (p *Peer) Err() error + func (p *Peer) Handle(method string, h Handler) *Server + func (p *Peer) Notify(ctx context.Context, req *Request) error + func (p *Peer) Serve() error + func (p *Peer) Server() *Server + func (p *Peer) Unregister(method string) bool + func (p *Peer) Wait() + type PeerOption func(*Peer) + func WithPeerCloseFunc(fn func() error) PeerOption + type ProcessOption func(*processConfig) + func WithDir(dir string) ProcessOption + func WithEnv(env []string) ProcessOption + func WithOnExit(fn func(error)) ProcessOption + func WithShutdownTimeout(d time.Duration) ProcessOption + func WithStderr(w io.Writer) ProcessOption + type Request struct + ID json.RawMessage + JSONRPC json.RawMessage + Method string + Params json.RawMessage + func (r *Request) IsNotification() bool + type Response struct + Error *Error + ID json.RawMessage + Result json.RawMessage + func (r *Response) UnmarshalJSON(data []byte) error + func (r Response) MarshalJSON() ([]byte, error) + type Server struct + func NewServer(opts ...Option) *Server + func (s *Server) Handle(method string, h Handler) *Server + func (s *Server) HandleMessage(ctx context.Context, raw []byte) ([]byte, bool) + func (s *Server) HandleRequest(ctx context.Context, req *Request) *Response + func (s *Server) Methods() []string + func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (s *Server) ServeStream(ctx context.Context, in io.Reader, out io.Writer) error + func (s *Server) Unregister(method string) bool + type StreamOption func(*StreamTransport) + func WithCloseFunc(fn func() error) StreamOption + type StreamTransport struct + func NewProcessTransport(name string, args []string, opts ...ProcessOption) (*StreamTransport, error) + func NewStreamTransport(in io.Reader, out io.Writer, opts ...StreamOption) *StreamTransport + func (t *StreamTransport) Call(ctx context.Context, req *Request) (*Response, error) + func (t *StreamTransport) CallBatch(ctx context.Context, reqs []*Request) ([]*Response, error) + func (t *StreamTransport) Close() error + func (t *StreamTransport) Notify(ctx context.Context, req *Request) error + type Transport interface + Call func(ctx context.Context, req *Request) (*Response, error) + Close func() error + Notify func(ctx context.Context, req *Request) error