modulepackage
0.0.0-20200317130110-931966b891fe
Repository: https://github.com/eclipse/che-go-jsonrpc.git
Documentation: pkg.go.dev
# README
Websocket API
JSON RPC 2.0 protocol is used for client-server communication, but:
params
is always json object(never array)- server to client notifications are treated as Events
the apis include some of the following fields:
{
"jsonrpc" : "2.0",
"method": "...",
"id": "...",
"params": { },
"error" : { },
"result" : { }
}
these fields are part of the protocol so they are not documented.
Websocket messages order
The order is respected
Message fragments MUST be delivered to the recipient in the order sent by the sender.
Helpful Sources
# Packages
Package event provides lightweight primitives for event-bus-consumer communication.
No description provided by the author
Package jsonrpcws provides implementation of jsonrpc.NativeConn based on websocket.
# Functions
FactoryDec uses given function to get an instance of object and then unmarshal params json into that object.
Get gets a single tunnel managed by default registry.
GetTunnels gets tunnels managed by default registry.
HandleRet converts handle function without transmitter to the HandleFunc.
NewArgsError creates error object from provided error and sets error code InvalidParamsErrorCode.
NewCloseError creates a new close error based on a given error.
NewError creates an error from the given error and code.
NewErrorf creates an error from the given code and formatted message.
NewManagedTunnel creates a new tunnel using given connection and DefaultRouter as request dispatcher, then the tunnel is saved in default registry and Go func is called.
NewRegistry creates a new registry.
NewRouter returns a new router.
NewTunnel creates a new tunnel.
PrintRoutes prints provided rpc routes by group.
RegRoute registers route using package DefaultRouter.
RegRoutesGroup registers routes group using package DefaultRouter.
RegRoutesGroups registers routes groups using package DefaultRouter.
Rm removes a given tunnel from the default registry.
Save saves a given tunnel is the default registry.
# Constants
ConnectedNotificationMethodName notification sent by Tunnel.SayHello().
DefaultAllowedResponseDelay is allowed time for reply to be sent.
DefaultMaxRequestHoldTimeout is how long a request stays in the queue and waits for the response to come, if reply is not made in time RespHandlerFunc is called with TimeoutError.
DefaultVersion is a version which is used by this package for all the types of sent/received data.
DefaultWatchQueuePeriod is how often request queue lookups requests.
InternalErrorCode is returned when error returned from the Route Handle is different from Error type.
InvalidParamsErrorCode indicates that handler parameters are considered as not valid.
InvalidRequestErrorCode indicates that request object is not valid, fails when route decoder can't decode params.
MethodNotFoundErrorCode indicates that there is no route for such method.
ParseErrorCode indicates that invalid JSON was received by the server.
TimeoutErrorCode is returned when timeout is reached where response should arrive.
# Variables
DefaultRegistry is package registry, which is used by NewManagedTunnel.
DefaultRouter is a default package router.
# Structs
CloseError is an error which MUST be published by NativeConn implementations and used to determine the cases when tunnel job should be stopped.
Error indicates any exceptional situation during operation execution, e.g an attempt to perform operation using invalid data.
Request is the identified call of the method.
Response is a reply on a certain request, which represents the result of the certain operation execution.
Route defines named operation and its handler.
Router is a simple request dispatcher.
RoutesGroup is named group of rpc routes.
Tunnel is high level jsonrpc transport layer which uses native connection to access low level transport routines.
TunnelNotification struct describing notification params sent by SayHello.
TunnelRegistry is a simple storage for tunnels.
# Interfaces
MethodHandler handles a certain method.
NativeConn provides low level interface for jsonrpc.Tunnel to communicate with native connection such as websocket.
ReqDispatcher is a single handler for all the tunnel incoming requests.
RespTransmitter provides interface which allows to respond to request from any method handler.
# Type aliases
DecodeFunc used to decode route params for forth handling by HandleFunc.
HandleFunc used to handle route request.
RespHandleFunc used to handle requests responses.