Documentation ¶
Index ¶
- func GetConnectOfRequest(ctx context.Context) drpcnet.Conn
- func GetMethodNameOfRequest(ctx context.Context) string
- func HandlerContextWithValue(requestCtx context.Context, key, value interface{})
- func SetConnectCtxChannel(ctx context.Context, ccc ConnectCtxChannel) context.Context
- func SetConnectOfRequest(ctx context.Context, conn drpcnet.Conn) context.Context
- type ConnectCtxChannel
- type ConnectCtxData
- type FailedNotif
- type Middleware
- type Server
- func (s *Server) AddListeners(l ...drpcnet.Listener)
- func (s *Server) CloseAllListeners()
- func (s *Server) CloseConnection(ctx context.Context) error
- func (s *Server) RegisterService(service *Service, srvType interface{})
- func (s *Server) SendMultiNotif(conns []drpcnet.Conn, notifName string, out proto.Message) ([]FailedNotif, error)
- func (s *Server) SendNotif(ctx context.Context, notifName string, out proto.Message) error
- func (s *Server) Serve() error
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConnectOfRequest ¶
GetConnectOfRequest returns connect of the request
func GetMethodNameOfRequest ¶
GetMethodNameOfRequest returns name of the request Use it in Middlewares or Handlers only
func HandlerContextWithValue ¶
HandlerContextWithValue sets value to ctx of this connect takes context of the handler and context arguments. This context will be available in the next request Do not use it more then 3 times per request, otherwise you get deadlock ╮( ̄ω ̄;)╭ Or use it with go to avoid blocking
func SetConnectCtxChannel ¶
func SetConnectCtxChannel(ctx context.Context, ccc ConnectCtxChannel) context.Context
SetConnectCtxChannel sets context channel of the connect to context It is not for users
Types ¶
type ConnectCtxChannel ¶
type ConnectCtxChannel chan *ConnectCtxData
ConnectCtxChannel is a context channel of the connection
func GetConnectCtxChannel ¶
func GetConnectCtxChannel(ctx context.Context) ConnectCtxChannel
GetConnectCtxChannel returns context channel of the connect from context
type ConnectCtxData ¶
type ConnectCtxData struct { Key interface{} Value interface{} }
ConnectCtxData is a type to receive context data to set in the Request connect
type FailedNotif ¶
FailedNotif this type contains message sending error and send connection
type Middleware ¶
Middleware you may added it to drpc.Service return error if you want to abort the RPC call Context will contain client connection, use GetConnectOfRequest()
type Server ¶
type Server struct { // OnAcceptNewConnect is callback that is called when listener get new connect // return false if you want to close connect // Default: accepts (true) OnAcceptNewConnect func(context.Context, drpcnet.Conn) bool // OnErrorAccept is callback that is called when getting connect ends with error // returns false if you want to stop listener // Default: listener keep work (true) OnErrorAccept func(context.Context, error) bool // OnErrorRead is callback that is called when reader of the connect returned error // Usually occurs EOF Error this is not important information // returns true if you want to close this connect // Default: connect will be closed (true) OnErrorRead func(context.Context, drpcnet.Conn, error) bool // OnErrorWrite is callback that is called when Write operation ends with error // return true if you want to Close connect // Default: connect will be closed (true) OnErrorWrite func(context.Context, drpcnet.Conn, error) bool // OnCloseConnect is callback that is called when server or client closed connection // takes context of the request and connection OnCloseConnect func(context.Context, drpcnet.Conn) // contains filtered or unexported fields }
Server side of the drpc Contains any listeners
func (*Server) AddListeners ¶
AddListeners adds new listeners to Server
func (*Server) CloseAllListeners ¶
func (s *Server) CloseAllListeners()
CloseAllListeners closes all listeners
func (*Server) CloseConnection ¶
CloseConnection takes context of the request closes connect and returns error of the close
func (*Server) RegisterService ¶
RegisterService register service with handlers
func (*Server) SendMultiNotif ¶
func (s *Server) SendMultiNotif(conns []drpcnet.Conn, notifName string, out proto.Message) ( []FailedNotif, error)
SendMultiNotif sends notification to several connection returns list of the failed and error
Directories ¶
Path | Synopsis |
---|---|
generator
The code generator for the plugin for the Google protocol buffer compiler.
|
The code generator for the plugin for the Google protocol buffer compiler. |
types
|
|
js/types
Package types is a generated protocol buffer package.
|
Package types is a generated protocol buffer package. |