Documentation ¶
Index ¶
- Constants
- func NewErrors() errors
- func WithErrors(es errors) func(c *Config)
- func WithNoReconnect() func(c *Config)
- func WithParamEncoder(t interface{}, encoder ParamEncoder) func(c *Config)
- func WithPingInterval(d time.Duration) func(c *Config)
- func WithReconnectBackoff(minDelay, maxDelay time.Duration) func(c *Config)
- func WithTimeout(d time.Duration) func(c *Config)
- type ClientCloser
- type ClientErr
- type Config
- type Error
- type Option
- type ParamDecoder
- type ParamEncoder
- type RPCConnectionError
- type RPCServer
- type Response
- type ServerConfig
- type ServerOption
Constants ¶
const DEFAULT_MAX_REQUEST_SIZE = 100 << 20 // 100 MiB
Limit request size. Ideally this limit should be specific for each field in the JSON request but as a simple defensive measure we just limit the entire HTTP body. Configured by WithMaxRequestSize.
const FirstUserCode = 2
const X_RPC_ERROR = "X-Rpc-Error"
const X_RPC_Handler = "X-Rpc-handler"
const X_RPC_ID = "X-Rpc-Id"
Variables ¶
This section is empty.
Functions ¶
func WithErrors ¶
func WithErrors(es errors) func(c *Config)
func WithNoReconnect ¶
func WithNoReconnect() func(c *Config)
func WithParamEncoder ¶
func WithParamEncoder(t interface{}, encoder ParamEncoder) func(c *Config)
func WithReconnectBackoff ¶
func WithTimeout ¶
Types ¶
type ClientCloser ¶
type ClientCloser func()
ClientCloser is used to close Client from further use
func NewClient ¶
func NewClient(ctx context.Context, 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(ctx context.Context, 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 ClientErr ¶ added in v0.2.0
type ClientErr struct {
// contains filtered or unexported fields
}
ClientErr is an error which occurred on the client side the library
type Error ¶ added in v0.2.0
type Error struct { Code errorCode `json:"code,omitempty"` Message string `json:"message,omitempty"` Detail any `json:"detail,omitempty"` Meta json.RawMessage `json:"meta,omitempty"` }
func NewMessage ¶ added in v0.2.0
type RPCConnectionError ¶
type RPCConnectionError struct {
// contains filtered or unexported fields
}
func (*RPCConnectionError) Error ¶
func (e *RPCConnectionError) Error() string
func (*RPCConnectionError) Unwrap ¶
func (e *RPCConnectionError) Unwrap() 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) AliasMethod ¶
type Response ¶ added in v0.2.0
type Response struct { *Error ID interface{} `json:"id,omitempty"` //Jsonrpc string `json:"jsonrpc,omitempty"` Result interface{} `json:"result,omitempty"` }
type ServerConfig ¶
type ServerConfig struct {
// contains filtered or unexported fields
}
type ServerOption ¶
type ServerOption func(c *ServerConfig)
func WithMaxRequestSize ¶
func WithMaxRequestSize(max int64) ServerOption
func WithParamDecoder ¶
func WithParamDecoder(t interface{}, decoder ParamDecoder) ServerOption
func WithServerErrors ¶
func WithServerErrors(es errors) ServerOption