fix: 错误队列不能只读前两个,增加了清除功能,读完全部错误队列
This commit is contained in:
@@ -16,9 +16,10 @@ import (
|
||||
var dialServer = dialServerWithOptions
|
||||
|
||||
type clientOptions struct {
|
||||
logger latencylog.Logger
|
||||
bindIP string
|
||||
bindDevice string
|
||||
logger latencylog.Logger
|
||||
txTimestampDebugLogger transport.TXTimestampDebugLogger
|
||||
bindIP string
|
||||
bindDevice string
|
||||
}
|
||||
|
||||
// Option 用于配置 Client 的可选行为,例如时延日志。
|
||||
@@ -31,6 +32,13 @@ func WithLogger(logger latencylog.Logger) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithTXTimestampDebugLogger 为 client 注入 TX errqueue 调试日志器。
|
||||
func WithTXTimestampDebugLogger(logger transport.TXTimestampDebugLogger) Option {
|
||||
return func(options *clientOptions) {
|
||||
options.txTimestampDebugLogger = logger
|
||||
}
|
||||
}
|
||||
|
||||
// WithBindIP 指定拨号时使用的本地源 IP。
|
||||
func WithBindIP(ip string) Option {
|
||||
return func(options *clientOptions) {
|
||||
@@ -74,6 +82,7 @@ func Dial(serverAddr, peerID string, opts ...Option) (*Client, error) {
|
||||
conn, err := transport.NewTCPConn(
|
||||
rawConn,
|
||||
transport.WithLogger(options.logger, latencylog.NodeRolePeer, peerID),
|
||||
transport.WithTXTimestampDebugLogger(options.txTimestampDebugLogger),
|
||||
)
|
||||
if err != nil {
|
||||
_ = rawConn.Close()
|
||||
|
||||
Reference in New Issue
Block a user