jsonrpc

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParse          = Error{/* contains filtered or unexported fields */}
	ErrInvalidRequest = Error{/* contains filtered or unexported fields */}
	ErrMethodNotFound = Error{/* contains filtered or unexported fields */}
	ErrInvalidParams  = Error{/* contains filtered or unexported fields */}
	ErrInternal       = Error{/* contains filtered or unexported fields */}
	ErrServer         = Error{/* contains filtered or unexported fields */}
)

Functions

func BuildErrResp

func BuildErrResp(id string, e Error) []byte

func ServeWithReconnect

func ServeWithReconnect(ctx context.Context, cli TransportWithConnect, caller Caller)

Types

type Caller

type Caller interface {
	Call(Request) (interface{}, error)
}

Caller interface this method invokes on request and encode response as jsonrpc response

type Error

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

func (Error) AddData

func (e Error) AddData(key string, value interface{}) Error

func (Error) Error

func (e Error) Error() string

func (Error) SetCode

func (e Error) SetCode(c int) Error

SetCode works only for ErrServer (code should be between -32099 and -32000)

func (Error) SetData

func (e Error) SetData(data map[string]interface{}) Error

type NextReader

type NextReader interface {
	NextReader() (io.Reader, error)
}

type NextWriter

type NextWriter interface {
	NextWriter() (io.WriteCloser, error)
}

type NotificationService added in v0.2.0

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

func (NotificationService) ID added in v0.2.0

func (n NotificationService) ID() string

func (NotificationService) Send added in v0.2.0

func (n NotificationService) Send(value interface{})

Send message (as jsonrpc notification call) to core

type RPC added in v0.2.0

type RPC interface {
	NewNotification(params objx.Map) NotificationService
}

type Request

type Request struct {
	JSONRPC string              `json:"jsonrpc"`
	Method  string              `json:"method"`
	ID      jsoniter.RawMessage `json:"id,omitempty"`
	Params  objx.Map            `json:"params"`
}

type Service

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

func New

func New(tr Transport, c Caller) Service

func (Service) NewNotification added in v0.2.0

func (s Service) NewNotification(params objx.Map) NotificationService

func (Service) Serve

func (s Service) Serve(ctx context.Context) error

type Transport

type Transport interface {
	NextWriter
	NextReader
}

type TransportWithConnect

type TransportWithConnect interface {
	Transport
	Connect() error
}

Jump to

Keyboard shortcuts

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