代码拉取完成,页面将自动刷新
package resolver
import (
"gitee.com/h79/goutils/common/logger"
"gitee.com/h79/goutils/discovery/resolver/builder"
)
type Resolver interface {
Resolve(target builder.Target) []builder.Address
}
var _ builder.Resolver = (*Bridge)(nil)
type Bridge struct {
build Builder
target builder.Target
conn builder.Connector
}
// ResolveNow builder.Resolver interface
func (cr *Bridge) ResolveNow() {
logger.Info("Bridge: ResolveNow, target= '%v'", cr.target)
cr.update()
}
// Close builder.Resolver interface
func (cr *Bridge) Close() {
logger.Info("Bridge: Close, target= '%v'", cr.target)
}
func (cr *Bridge) update() {
if addrs := cr.build.Resolve(cr.target); len(addrs) > 0 {
cr.conn.UpdateState(builder.State{Addresses: addrs, Attributes: nil})
}
}
func NewResolver(target builder.Target, cc builder.Connector, builder Builder) builder.Resolver {
r := &Bridge{
target: target,
conn: cc,
build: builder,
}
r.update()
return r
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。