jsonrpc

package
v0.0.0-...-1010016 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ContentModifiedCode = -32801
View Source
const InternalErrorCode = -32603
View Source
const InvalidParamsCode = -32602
View Source
const InvalidRequestCode = -32600
View Source
const MethodNotFoundCode = -32601
View Source
const ParseErrorCode = -32700
View Source
const RequestCancelledCode = -32800
View Source
const ServerNotInitializedCode = -32002
View Source
const UnknownErrorCodeCode = -32001

Variables

View Source
var ContentModified = BuildInError{
	Code:    ContentModifiedCode,
	Message: "ContentModified",
}
View Source
var InternalError = BuildInError{
	Code:    InternalErrorCode,
	Message: "InternalError",
}
View Source
var InvalidParams = BuildInError{
	Code:    InvalidParamsCode,
	Message: "InvalidParams",
}
View Source
var InvalidRequest = BuildInError{
	Code:    InvalidRequestCode,
	Message: "InvalidRequest",
}
View Source
var MethodNotFound = BuildInError{
	Code:    MethodNotFoundCode,
	Message: "MethodNotFound",
}
View Source
var ParseError = BuildInError{
	Code:    ParseErrorCode,
	Message: "ParseError",
}
View Source
var RequestCancelled = BuildInError{
	Code:    RequestCancelledCode,
	Message: "RequestCancelled",
}
View Source
var ServerNotInitialized = BuildInError{
	Code:    ServerNotInitializedCode,
	Message: "ServerNotInitialized",
}
View Source
var UnknownErrorCode = BuildInError{
	Code:    UnknownErrorCodeCode,
	Message: "UnknownErrorCode",
}

Functions

This section is empty.

Types

type BaseMessage

type BaseMessage struct {
	Jsonrpc string `json:"jsonrpc"`
}

type BuildInError

type BuildInError = ResponseError

type CancelParams

type CancelParams struct {
	ID interface{} `json:"id"` // the method id should be canceled
}

type CloserReader

type CloserReader interface {
	io.Reader
	io.Closer
}

func NewFakeCloserReader

func NewFakeCloserReader(r io.Reader) CloserReader

type CloserWriter

type CloserWriter interface {
	io.Writer
	io.Closer
}

func NewFakeCloserWriter

func NewFakeCloserWriter(w io.Writer) CloserWriter

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

The connection of rpc, not limited to net.Conn

func NewConn

func NewConn(reader CloserReader, writer CloserWriter) *Conn

func NewNotCloseConn

func NewNotCloseConn(reader io.Reader, writer io.Writer) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Read

func (c *Conn) Read(p []byte) (n int, err error)

func (*Conn) Write

func (c *Conn) Write(p []byte) (n int, err error)

type MethodInfo

type MethodInfo struct {
	Name       string
	NewRequest func() interface{}
	Handler    func(ctx context.Context, req interface{}) (interface{}, error)
}

func CancelRequest

func CancelRequest() MethodInfo

type NotificationMessage

type NotificationMessage struct {
	BaseMessage
	Method string          `json:"method"` // starts with "/$", server build-in methods.
	Params json.RawMessage `json:"params"` // params, is some struct or slice
}

type ProgressParams

type ProgressParams struct {
	Token interface{} `json:"token"` // int or string
	/**
	 * The progress data.
	 */
	Value interface{} `json:"value"`
}

type ReaderWriter

type ReaderWriter interface {
	io.Reader
	io.Writer
	io.Closer
}

type RequestMessage

type RequestMessage struct {
	BaseMessage
	ID     interface{}     `json:"id"` // may be int or string
	Method string          `json:"method"`
	Params json.RawMessage `json:"params"` // params, is some struct or slice
}

type ResponseError

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

func (ResponseError) Error

func (r ResponseError) Error() string

type ResponseMessage

type ResponseMessage struct {
	BaseMessage
	ID     interface{}    `json:"id"` // may be int or string
	Result interface{}    `json:"result"`
	Error  *ResponseError `json:"error"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) Handle

func (s *Server) Handle(conn ReaderWriter)

func (*Server) RegisterMethod

func (s *Server) RegisterMethod(m MethodInfo)

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) Start

func (s *Session) Start()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL