Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RtRefreshManager ¶
type RtRefreshManager struct {
// contains filtered or unexported fields
}
RtRefreshManager 路由表刷新管理器
func NewRtRefreshManager ¶
func NewRtRefreshManager(h host.Host, rt *kbucket.RoutingTable, autoRefresh bool, refreshKeyGenFnc func(cpl uint) (string, error), refreshQueryFnc func(ctx context.Context, key string) error, refreshPingFnc func(ctx context.Context, p peer.ID) error, refreshQueryTimeout time.Duration, refreshInterval time.Duration, successfulOutboundQueryGracePeriod time.Duration, refreshDoneCh chan struct{}) (*RtRefreshManager, error)
NewRtRefreshManager 创建新的路由表刷新管理器 参数:
- h: host.Host 主机
- rt: *kbucket.RoutingTable 路由表
- autoRefresh: bool 是否自动刷新
- refreshKeyGenFnc: func(cpl uint) (string, error) 生成刷新键的函数
- refreshQueryFnc: func(ctx context.Context, key string) error 执行刷新查询的函数
- refreshPingFnc: func(ctx context.Context, p peer.ID) error 执行ping的函数
- refreshQueryTimeout: time.Duration 刷新查询超时时间
- refreshInterval: time.Duration 刷新间隔
- successfulOutboundQueryGracePeriod: time.Duration 成功外发查询的宽限期
- refreshDoneCh: chan struct{} 刷新完成通道
返回值:
- *RtRefreshManager 刷新管理器实例
- error 错误信息
func (*RtRefreshManager) Close ¶
func (r *RtRefreshManager) Close() error
Close 关闭刷新管理器 返回值:
- error 错误信息
func (*RtRefreshManager) Refresh ¶
func (r *RtRefreshManager) Refresh(force bool) <-chan error
Refresh 请求刷新管理器刷新路由表 如果force参数设置为true,所有桶都将被刷新,不考虑上次刷新时间
返回的通道将阻塞直到刷新完成,然后返回错误并关闭。该通道是带缓冲的,可以安全地忽略 参数:
- force: bool 是否强制刷新
返回值:
- <-chan error 错误通道
func (*RtRefreshManager) RefreshNoWait ¶
func (r *RtRefreshManager) RefreshNoWait()
RefreshNoWait 请求刷新管理器刷新路由表 如果请求无法通过,则继续执行而不阻塞
Click to show internal directories.
Click to hide internal directories.