Documentation ¶
Index ¶
- type Check
- type DiscoveryClient
- func (consulClient *DiscoveryClient) Deregister(ctx context.Context, instanceId string) error
- func (consulClient *DiscoveryClient) DiscoverServices(ctx context.Context, serviceName string) ([]*InstanceInfo, error)
- func (consulClient *DiscoveryClient) Register(ctx context.Context, serviceName, instanceId, healthCheckUrl string, ...) error
- type InstanceInfo
- type Weights
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check struct { DeregisterCriticalServiceAfter string `json:"DeregisterCriticalServiceAfter"` // 多久之后注销服务 Args []string `json:"Args,omitempty"` // 请求参数 HTTP string `json:"HTTP"` // 健康检查地址 Interval string `json:"Interval,omitempty"` // Consul 主动检查间隔 TTL string `json:"TTL,omitempty"` // 服务实例主动维持心跳间隔,与Interval只存其一 }
type DiscoveryClient ¶
type DiscoveryClient struct {
// contains filtered or unexported fields
}
func NewDiscoveryClient ¶
func NewDiscoveryClient(host string, port int) *DiscoveryClient
func (*DiscoveryClient) Deregister ¶
func (consulClient *DiscoveryClient) Deregister(ctx context.Context, instanceId string) error
func (*DiscoveryClient) DiscoverServices ¶
func (consulClient *DiscoveryClient) DiscoverServices(ctx context.Context, serviceName string) ([]*InstanceInfo, error)
type InstanceInfo ¶
type InstanceInfo struct { ID string `json:"ID"` // 服务实例ID Service string `json:"Service,omitempty"` // 服务发现时返回的服务名 Name string `json:"Name"` // 服务名 Tags []string `json:"Tags,omitempty"` // 标签,可用于进行服务过滤 Address string `json:"Address"` // 服务实例HOST Port int `json:"Port"` // 服务实例端口 Meta map[string]string `json:"Meta,omitempty"` // 元数据 EnableTagOverride bool `json:"EnableTagOverride"` // 是否允许标签覆盖 Check `json:"Check,omitempty"` // 健康检查相关配置 Weights `json:"Weights,omitempty"` // 权重 CurWeight int `json:"CurWeights,omitempty"` // 权重 }
服务实例结构体
Click to show internal directories.
Click to hide internal directories.