go-plugins: github.com/micro/go-plugins/codec/jsonrpc2 Index | Files

package jsonrpc2

import "github.com/micro/go-plugins/codec/jsonrpc2"

Package jsonrpc2 provides a json-rpc 2.0 codec

Based on powerman/rpc-codec: The MIT License (MIT) Copyright (c) 2015 Alex Efros


Package Files

client.go errors.go jsonrpc2.go license.go server.go

func NewCodec Uses

func NewCodec(rwc io.ReadWriteCloser) codec.Codec

type Error Uses

type Error struct {
    Code    int         `json:"code"`
    Message string      `json:"message"`
    Data    interface{} `json:"data,omitempty"`

Error represent JSON-RPC 2.0 "Error object".

func NewError Uses

func NewError(code int, message string) *Error

NewError returns an Error with given code and message.

func ServerError Uses

func ServerError(rpcerr error) *Error

ServerError convert errors returned by Client.Call() into Error. User should check for rpc.ErrShutdown and io.ErrUnexpectedEOF before calling ServerError.

func (*Error) Error Uses

func (e *Error) Error() string

Error returns JSON representation of Error.

Package jsonrpc2 imports 11 packages (graph). Updated 2020-03-23. Refresh now. Tools for package owners.