Documentation
¶
Overview ¶
Package conn 提供连接管理相关的工具。
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrConnectionUnavailable 在连接不可用时由 Write 方法返回。
Functions ¶
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 管理一个 net.Conn 的生命周期。
通过 Take 获取连接,通过 Put 报告错误。 当 Put 收到非 nil error 时,当前连接失效,Manager 自动重连(指数退避)。
func NewDefaultManager ¶
NewDefaultManager 创建一个使用默认配置的连接管理器。 使用 net.Dial 和 time.After。
func NewManager ¶
NewManager 创建一个连接管理器。
参数:
- d: 连接创建函数
- network/address: 传递给 Dialer
- after: 时间控制函数(测试可注入,生产用 time.After)
Click to show internal directories.
Click to hide internal directories.