Documentation
¶
Index ¶
- type Client
- type ConnectionHandler
- type IDGenerator
- type Message
- type MessageBroker
- type MessageHandler
- type MessagePair
- type RequestMessageHandler
- type RpcConnection
- func (c *RpcConnection) AddMetadata(key, value string)
- func (c *RpcConnection) Close()
- func (c *RpcConnection) GetMetadata(key string) (string, bool)
- func (c *RpcConnection) ID() uint64
- func (c *RpcConnection) OnClose(handle func())
- func (c *RpcConnection) OnRequest(handle MessageHandler)
- func (c *RpcConnection) Ping() (int, error)
- func (c *RpcConnection) RemoveMetadata(key string)
- func (c *RpcConnection) Request(data []byte) ([]byte, error)
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Addr string
Port uint
RetryDelay time.Duration
// contains filtered or unexported fields
}
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
func (*Client) GetPingValue ¶
func (*Client) OnRequest ¶
func (c *Client) OnRequest(handle RequestMessageHandler)
type ConnectionHandler ¶
type ConnectionHandler func(*RpcConnection)
type IDGenerator ¶
type IDGenerator struct {
// contains filtered or unexported fields
}
IDGenerator 用于生成唯一的消息ID
type MessageBroker ¶
type MessageBroker struct {
// contains filtered or unexported fields
}
MessageBroker 负责管理消息配对和等待回复
func NewMessageBroker ¶
func NewMessageBroker(timeout time.Duration) *MessageBroker
NewMessageBroker 创建一个新的消息 Broker
func (*MessageBroker) ReceiveResponse ¶
func (b *MessageBroker) ReceiveResponse(response *Message) bool
ReceiveResponse 接收回复消息,并通知等待的请求方
type MessageHandler ¶
type MessageHandler func(*RpcConnection, []byte) []byte
type MessagePair ¶
MessagePair 表示一个消息和其回复消息的配对
type RequestMessageHandler ¶
type RpcConnection ¶
type RpcConnection struct {
// contains filtered or unexported fields
}
func NewRpcConnection ¶
func NewRpcConnection(id uint64, ctx context.Context, conn quic.Connection, timeout uint) *RpcConnection
func (*RpcConnection) AddMetadata ¶
func (c *RpcConnection) AddMetadata(key, value string)
func (*RpcConnection) GetMetadata ¶
func (c *RpcConnection) GetMetadata(key string) (string, bool)
func (*RpcConnection) ID ¶ added in v0.0.4
func (c *RpcConnection) ID() uint64
func (*RpcConnection) OnClose ¶
func (c *RpcConnection) OnClose(handle func())
func (*RpcConnection) OnRequest ¶
func (c *RpcConnection) OnRequest(handle MessageHandler)
func (*RpcConnection) Ping ¶
func (c *RpcConnection) Ping() (int, error)
func (*RpcConnection) RemoveMetadata ¶
func (c *RpcConnection) RemoveMetadata(key string)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) OnConnection ¶
func (s *Server) OnConnection(handle ConnectionHandler)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.