Documentation ¶
Index ¶
- Variables
- func MarshalPayload(valu interface{}) (*nacospb.Payload, error)
- func ValueClientIP(ctx context.Context) string
- func ValueConnID(ctx context.Context) string
- type Client
- type ClientIPKey
- type ClientInFlights
- type ConnIDKey
- type ConnectionEvent
- type ConnectionInfoKey
- type ConnectionManager
- func (h *ConnectionManager) GetClient(id string) (*Client, bool)
- func (h *ConnectionManager) GetClientByAddr(addr string) (*Client, bool)
- func (h *ConnectionManager) GetStream(connID string) *SyncServerStream
- func (h *ConnectionManager) HandleConn(ctx context.Context, s stats.ConnStats)
- func (h *ConnectionManager) HandleRPC(ctx context.Context, s stats.RPCStats)
- func (h *ConnectionManager) InFlights() *InFlights
- func (h *ConnectionManager) ListConnections() map[string]*Client
- func (h *ConnectionManager) OnAccept(conn net.Conn)
- func (h *ConnectionManager) OnClose()
- func (h *ConnectionManager) OnRelease(conn net.Conn)
- func (h *ConnectionManager) RefreshClient(ctx context.Context)
- func (h *ConnectionManager) RegisterConnection(ctx context.Context, payload *nacospb.Payload, ...) error
- func (h *ConnectionManager) TagConn(ctx context.Context, connInfo *stats.ConnTagInfo) context.Context
- func (h *ConnectionManager) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context
- func (h *ConnectionManager) UnRegisterConnection(connID string)
- type ConnectionMeta
- type EventType
- type InFlight
- type InFlights
- type RequestHandler
- type RequestHandlerWarrper
- type SyncServerStream
Constants ¶
This section is empty.
Variables ¶
var ( ErrorNoSuchPayloadType = errors.New("not such payload type") ErrorInvalidRequestBodyType = errors.New("invalid request body type") )
Functions ¶
func MarshalPayload ¶
MarshalPayload .
func ValueClientIP ¶
func ValueConnID ¶
Types ¶
type Client ¶
type Client struct { ID string `json:"id"` Addr *net.TCPAddr `json:"addr"` ConnMeta ConnectionMeta `json:"conn_meta"` // contains filtered or unexported fields }
Client
func (*Client) LoadStream ¶
func (c *Client) LoadStream() (*SyncServerStream, bool)
func (*Client) SetStreamRef ¶
func (c *Client) SetStreamRef(stream *SyncServerStream)
type ClientIPKey ¶
type ClientIPKey struct{}
type ClientInFlights ¶
type ClientInFlights struct {
// contains filtered or unexported fields
}
ClientInFlights
type ConnectionEvent ¶
ConnectionEvent
type ConnectionInfoKey ¶
type ConnectionInfoKey struct{}
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func NewConnectionManager ¶
func NewConnectionManager() *ConnectionManager
func (*ConnectionManager) GetClient ¶
func (h *ConnectionManager) GetClient(id string) (*Client, bool)
func (*ConnectionManager) GetClientByAddr ¶
func (h *ConnectionManager) GetClientByAddr(addr string) (*Client, bool)
func (*ConnectionManager) GetStream ¶
func (h *ConnectionManager) GetStream(connID string) *SyncServerStream
func (*ConnectionManager) HandleConn ¶
func (h *ConnectionManager) HandleConn(ctx context.Context, s stats.ConnStats)
HandleConn processes the Conn stats.
func (*ConnectionManager) HandleRPC ¶
func (h *ConnectionManager) HandleRPC(ctx context.Context, s stats.RPCStats)
HandleRPC processes the RPC stats.
func (*ConnectionManager) InFlights ¶
func (h *ConnectionManager) InFlights() *InFlights
func (*ConnectionManager) ListConnections ¶
func (h *ConnectionManager) ListConnections() map[string]*Client
func (*ConnectionManager) OnAccept ¶
func (h *ConnectionManager) OnAccept(conn net.Conn)
OnAccept call when net.Conn accept
func (*ConnectionManager) OnClose ¶
func (h *ConnectionManager) OnClose()
OnClose call when net.Listener close
func (*ConnectionManager) OnRelease ¶
func (h *ConnectionManager) OnRelease(conn net.Conn)
OnRelease call when net.Conn release
func (*ConnectionManager) RefreshClient ¶
func (h *ConnectionManager) RefreshClient(ctx context.Context)
func (*ConnectionManager) RegisterConnection ¶
func (h *ConnectionManager) RegisterConnection(ctx context.Context, payload *nacospb.Payload, req *nacospb.ConnectionSetupRequest) error
func (*ConnectionManager) TagConn ¶
func (h *ConnectionManager) TagConn(ctx context.Context, connInfo *stats.ConnTagInfo) context.Context
TagConn can attach some information to the given context. The returned context will be used for stats handling. For conn stats handling, the context used in HandleConn for this connection will be derived from the context returned. For RPC stats handling,
- On server side, the context used in HandleRPC for all RPCs on this
connection will be derived from the context returned.
- On client side, the context is not derived from the context returned.
func (*ConnectionManager) TagRPC ¶
func (h *ConnectionManager) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context
TagRPC can attach some information to the given context. The context used for the rest lifetime of the RPC will be derived from the returned context.
func (*ConnectionManager) UnRegisterConnection ¶
func (h *ConnectionManager) UnRegisterConnection(connID string)
type ConnectionMeta ¶
type ConnectionMeta struct { ConnectType string ClientIp string RemoteIp string RemotePort int LocalPort int Version string ConnectionId string CreateTime time.Time AppName string Tenant string Labels map[string]string ClientAttributes nacospb.ClientAbilities }
ConnectionMeta
func ValueConnMeta ¶
func ValueConnMeta(ctx context.Context) ConnectionMeta
type EventType ¶
type EventType int32
const ( ClientConnectionEvent = "ClientConnectionEvent" EventClientConnected EventType EventClientDisConnected )
type InFlight ¶
type InFlight struct { ConnID string RequestID string Callback func(map[string]interface{}, nacospb.BaseResponse, error) ExpireTime time.Time Attachment map[string]interface{} // contains filtered or unexported fields }
InFlight
type InFlights ¶
type InFlights struct {
// contains filtered or unexported fields
}
InFlights
func NewInFlights ¶
func (*InFlights) AddInFlight ¶
AddInFlight 添加一个待回调通知的 InFligjt
func (*InFlights) NotifyInFlight ¶
func (i *InFlights) NotifyInFlight(connID string, resp nacospb.BaseResponse)
type RequestHandler ¶
type RequestHandler func(context.Context, nacospb.BaseRequest, nacospb.RequestMeta) (nacospb.BaseResponse, error)
RequestHandler
type RequestHandlerWarrper ¶
type RequestHandlerWarrper struct { Handler RequestHandler PayloadBuilder func() nacospb.CustomerPayload }
RequestHandlerWarrper
type SyncServerStream ¶
type SyncServerStream struct { Stream grpc.ServerStream // contains filtered or unexported fields }
SyncServerStream
func (*SyncServerStream) Context ¶
func (s *SyncServerStream) Context() context.Context
Context returns the context for this stream.
func (*SyncServerStream) SendMsg ¶
func (s *SyncServerStream) SendMsg(m interface{}) error