jsonrpc

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: Apache-2.0, MIT Imports: 25 Imported by: 382

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithParamEncoder added in v0.1.1

func WithParamEncoder(t interface{}, encoder ParamEncoder) func(c *Config)

func WithReconnectBackoff added in v0.1.1

func WithReconnectBackoff(minDelay, maxDelay time.Duration) func(c *Config)

Types

type ClientCloser

type ClientCloser func()

ClientCloser is used to close Client from further use

func NewClient

func NewClient(addr string, namespace string, handler interface{}, requestHeader http.Header) (ClientCloser, error)

NewClient creates new jsonrpc 2.0 client

handler must be pointer to a struct with function fields Returned value closes the client connection TODO: Example

func NewMergeClient

func NewMergeClient(addr string, namespace string, outs []interface{}, requestHeader http.Header, opts ...Option) (ClientCloser, error)

NewMergeClient is like NewClient, but allows to specify multiple structs to be filled in the same namespace, using one connection

type Config

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

type ErrClient

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

ErrClient is an error which occurred on the client side the library

func (*ErrClient) Error

func (e *ErrClient) Error() string

func (*ErrClient) Unwrap

func (e *ErrClient) Unwrap(err error) error

Unwrap unwraps the actual error

type Option

type Option func(c *Config)

type ParamDecoder added in v0.1.1

type ParamDecoder func(json []byte) (reflect.Value, error)

type ParamEncoder added in v0.1.1

type ParamEncoder func(reflect.Value) (reflect.Value, error)

type RPCServer

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

RPCServer provides a jsonrpc 2.0 http server handler

func NewServer

func NewServer(opts ...ServerOption) *RPCServer

NewServer creates new RPCServer instance

func (*RPCServer) Register

func (s *RPCServer) Register(namespace string, handler interface{})

Register registers new RPC handler

Handler is any value with methods defined

func (*RPCServer) ServeHTTP

func (s *RPCServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

TODO: return errors to clients per spec

type ServerConfig added in v0.1.1

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

type ServerOption added in v0.1.1

type ServerOption func(c *ServerConfig)

func WithParamDecoder added in v0.1.1

func WithParamDecoder(t interface{}, decoder ParamDecoder) ServerOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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