Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultNamespace 是 Consul 轻量实现下的默认命名空间。 DefaultNamespace = "default" // DefaultCacheTTL 是 Consul endpoint 缓存的默认有效期。 DefaultCacheTTL = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func NewConnectionManager ¶
func NewConnectionManager(client *api.Client, conf *Config, options microInvocation.ConnectionManagerOptions) (*microInvocation.ConnectionManager, error)
NewConnectionManager 创建基于 Consul Locator 的连接管理器。
Types ¶
type Config ¶ added in v0.0.5
type Config struct {
// Namespace 是默认命名空间。
Namespace string `json:"namespace"`
// TargetOptions 表示通用 target 构造选项。
TargetOptions microInvocation.TargetOptions `json:"target_options"`
// PreferServiceDNS 控制是否优先走 service 级 DNS 目标。
PreferServiceDNS bool `json:"prefer_service_dns"`
// CacheTTL 控制健康实例列表缓存的有效期。
CacheTTL time.Duration `json:"cache_ttl"`
}
Config 定义 Consul invocation 轻量实现配置。
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
Locator 是基于 Consul 的 invocation 定位器。
它与 etcd 轻量实现保持一致: - 若已具备稳定 service DNS,则优先返回 DNS target; - 否则读取 Consul 健康实例列表,在本地做轻量 endpoint 选择。
func NewLocator ¶
NewLocator 创建 Consul invocation 定位器。
func (*Locator) Resolve ¶
func (l *Locator) Resolve(ctx context.Context, ref microInvocation.ServiceRef) (microInvocation.Target, error)
Resolve 根据 ServiceRef 解析最终 Target。
Click to show internal directories.
Click to hide internal directories.