Versions in this module Expand all Collapse all v1 v1.8.8 May 11, 2023 Changes in this version + const CodeInternalJSONRPCError + const CodeInvalidParams + const CodeInvalidjsonrpcRequest + const CodeMethodNotFound + const CodeParseJSONRPCError + const CodeUnknownJSONRPCError + const ReaderBuffsize + const WriterBuffsize + const XErrorMessage + const XHeartbeat + const XMessageID + const XMessageStatusType + const XMessageType + const XMeta + const XOneway + const XSerializeType + const XServiceMethod + const XServicePath + const XVersion + var ErrNotAccept = errors.New("server refused the connection") + var ErrReqReachLimit = errors.New("request reached rate limit") + var ErrServerClosed = errors.New("http: Server closed") + var HttpConnContextKey = &contextKey + var RemoteConnContextKey = &contextKey + var StartRequestContextKey = &contextKey + var StartSendRequestContextKey = &contextKey + var TagContextKey = &contextKey + func HTTPRequest2RpcxRequest(r *http.Request) (*protocol.Message, error) + func RegisterMakeListener(network string, ml MakeListener) + type CMuxPlugin interface + MuxMatch func(m cmux.CMux) + type CORSOptions = cors.Options + func AllowAllCORSOptions() *CORSOptions + type Context struct + func NewContext(ctx *share.Context, conn net.Conn, req *protocol.Message, async bool) *Context + func (ctx *Context) Bind(v interface{}) error + func (ctx *Context) DeleteKey(key interface{}) + func (ctx *Context) Get(key interface{}) interface{} + func (ctx *Context) Metadata() map[string]string + func (ctx *Context) Payload() []byte + func (ctx *Context) ServiceMethod() string + func (ctx *Context) ServicePath() string + func (ctx *Context) SetValue(key, val interface{}) + func (ctx *Context) Write(v interface{}) error + func (ctx *Context) WriteError(err error) error + type DownloadFileHandler func(conn net.Conn, args *share.DownloadFileArgs) + type FileTransfer struct + Addr string + AdvertiseAddr string + func NewFileTransfer(addr string, handler FileTransferHandler, ...) *FileTransfer + func (s *FileTransfer) Start() error + func (s *FileTransfer) Stop() error + type FileTransferHandler func(conn net.Conn, args *share.FileTransferArgs) + type FileTransferService struct + FileTransfer *FileTransfer + func (s *FileTransferService) DownloadFile(ctx context.Context, args *share.DownloadFileArgs, ...) error + func (s *FileTransferService) TransferFile(ctx context.Context, args *share.FileTransferArgs, ...) error + type Handler func(ctx *Context) error + type HeartbeatPlugin interface + HeartbeatRequest func(ctx context.Context, req *protocol.Message) error + type ID struct + Name string + Number int64 + func (id *ID) MarshalJSON() ([]byte, error) + func (id *ID) String() string + func (id *ID) UnmarshalJSON(data []byte) error + type JSONRPCError struct + Code int64 + Data *json.RawMessage + Message string + func (err *JSONRPCError) JSONRPCError() string + type MakeListener func(s *Server, address string) (ln net.Listener, err error) + type OptionFn func(*Server) + func WithAsyncWrite() OptionFn + func WithCustomPool(pool WorkerPool) OptionFn + func WithPool(maxWorkers, maxCapacity int, options ...pond.Option) OptionFn + func WithReadTimeout(readTimeout time.Duration) OptionFn + func WithTCPKeepAlivePeriod(period time.Duration) OptionFn + func WithTLSConfig(cfg *tls.Config) OptionFn + func WithWriteTimeout(writeTimeout time.Duration) OptionFn + type Plugin interface + type PluginContainer interface + Add func(plugin Plugin) + All func() []Plugin + DoHeartbeatRequest func(ctx context.Context, req *protocol.Message) error + DoPostCall func(ctx context.Context, serviceName, methodName string, args, reply interface{}) (interface{}, error) + DoPostConnAccept func(net.Conn) (net.Conn, bool) + DoPostConnClose func(net.Conn) bool + DoPostReadRequest func(ctx context.Context, r *protocol.Message, e error) error + DoPostWriteRequest func(ctx context.Context, r *protocol.Message, e error) error + DoPostWriteResponse func(context.Context, *protocol.Message, *protocol.Message, error) error + DoPreCall func(ctx context.Context, serviceName, methodName string, args interface{}) (interface{}, error) + DoPreHandleRequest func(ctx context.Context, req *protocol.Message) error + DoPreReadRequest func(ctx context.Context) error + DoPreWriteRequest func(ctx context.Context) error + DoPreWriteResponse func(context.Context, *protocol.Message, *protocol.Message, error) error + DoRegister func(name string, rcvr interface{}, metadata string) error + DoRegisterFunction func(serviceName, fname string, fn interface{}, metadata string) error + DoUnregister func(name string) error + MuxMatch func(m cmux.CMux) + Remove func(plugin Plugin) + type PostCallPlugin interface + PostCall func(ctx context.Context, serviceName, methodName string, args, reply interface{}) (interface{}, error) + type PostConnAcceptPlugin interface + HandleConnAccept func(net.Conn) (net.Conn, bool) + type PostConnClosePlugin interface + HandleConnClose func(net.Conn) bool + type PostReadRequestPlugin interface + PostReadRequest func(ctx context.Context, r *protocol.Message, e error) error + type PostWriteRequestPlugin interface + PostWriteRequest func(ctx context.Context, r *protocol.Message, e error) error + type PostWriteResponsePlugin interface + PostWriteResponse func(context.Context, *protocol.Message, *protocol.Message, error) error + type PreCallPlugin interface + PreCall func(ctx context.Context, serviceName, methodName string, args interface{}) (interface{}, error) + type PreHandleRequestPlugin interface + PreHandleRequest func(ctx context.Context, r *protocol.Message) error + type PreReadRequestPlugin interface + PreReadRequest func(ctx context.Context) error + type PreWriteRequestPlugin interface + PreWriteRequest func(ctx context.Context) error + type PreWriteResponsePlugin interface + PreWriteResponse func(context.Context, *protocol.Message, *protocol.Message, error) error + type RegisterFunctionPlugin interface + RegisterFunction func(serviceName, fname string, fn interface{}, metadata string) error + type RegisterPlugin interface + Register func(name string, rcvr interface{}, metadata string) error + Unregister func(name string) error + type Reset interface + Reset func() + type Server struct + AsyncWrite bool + AuthFunc func(ctx context.Context, req *protocol.Message, token string) error + DisableHTTPGateway bool + DisableJSONRPC bool + HandleServiceError func(error) + Plugins PluginContainer + ServerErrorFunc func(res *protocol.Message, err error) string + func NewServer(options ...OptionFn) *Server + func (s *Server) ActiveClientConn() []net.Conn + func (s *Server) AddHandler(servicePath, serviceMethod string, handler func(*Context) error) + func (s *Server) Address() net.Addr + func (s *Server) Close() error + func (s *Server) EnableFileTransfer(serviceName string, fileTransfer *FileTransfer) + func (s *Server) EnableStreamService(serviceName string, streamService *StreamService) + func (s *Server) Register(rcvr interface{}, metadata string) error + func (s *Server) RegisterFunction(servicePath string, fn interface{}, metadata string) error + func (s *Server) RegisterFunctionName(servicePath string, name string, fn interface{}, metadata string) error + func (s *Server) RegisterName(name string, rcvr interface{}, metadata string) error + func (s *Server) RegisterOnRestart(f func(s *Server)) + func (s *Server) RegisterOnShutdown(f func(s *Server)) + func (s *Server) Restart(ctx context.Context) error + func (s *Server) SendMessage(conn net.Conn, servicePath, serviceMethod string, metadata map[string]string, ...) error + func (s *Server) Serve(network, address string) (err error) + func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) + func (s *Server) ServeListener(network string, ln net.Listener) (err error) + func (s *Server) ServeWS(conn *websocket.Conn) + func (s *Server) SetCORS(options *CORSOptions) + func (s *Server) Shutdown(ctx context.Context) error + func (s *Server) UnregisterAll() error + type StreamAcceptor func(ctx context.Context, args *share.StreamServiceArgs) bool + type StreamHandler func(conn net.Conn, args *share.StreamServiceArgs) + type StreamService struct + Addr string + AdvertiseAddr string + func NewStreamService(addr string, streamHandler StreamHandler, acceptor StreamAcceptor, waitNum int) *StreamService + func (s *StreamService) Start() error + func (s *StreamService) Stop() error + func (s *StreamService) Stream(ctx context.Context, args *share.StreamServiceArgs, ...) error + type VersionTag struct + func (VersionTag) MarshalJSON() ([]byte, error) + func (VersionTag) UnmarshalJSON(data []byte) error + type WorkerPool interface + Stop func() + StopAndWait func() + StopAndWaitFor func(deadline time.Duration) + Submit func(task func())