Documentation ¶
Index ¶
- type Check
- type ConsulDiscoverClient
- func (consulClient *ConsulDiscoverClient) DeRegister(instanceId string, logger *log.Logger) bool
- func (consulClient *ConsulDiscoverClient) DiscoverServices(serviceName string, logger *log.Logger) []interface{}
- func (consulClient *ConsulDiscoverClient) Register(serviceName, instanceId, healthCheckUrl string, instanceHost string, ...) bool
- type DiscoveryClient
- type InstanceInfo
- type KitDiscoverClient
- func (consulClient *KitDiscoverClient) DeRegister(instanceId string, logger *log.Logger) bool
- func (consulClient *KitDiscoverClient) DiscoverServices(serviceName string, logger *log.Logger) []interface{}
- func (consulClient *KitDiscoverClient) Register(serviceName, instanceId, healthCheckUrl string, instanceHost string, ...) bool
- 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 ConsulDiscoverClient ¶
func (*ConsulDiscoverClient) DeRegister ¶
func (consulClient *ConsulDiscoverClient) DeRegister(instanceId string, logger *log.Logger) bool
DeRegister 注销微服务 @param instanceId 服务ID @param logger 日志对象
func (*ConsulDiscoverClient) DiscoverServices ¶
func (consulClient *ConsulDiscoverClient) DiscoverServices(serviceName string, logger *log.Logger) []interface{}
DiscoverServices 发现服务 @param serviceName 服务名称 @param logger 日志对象
func (*ConsulDiscoverClient) Register ¶
func (consulClient *ConsulDiscoverClient) Register(serviceName, instanceId, healthCheckUrl string, instanceHost string, instancePort int, meta map[string]string, logger *log.Logger) bool
Register 注册微服务 @param serviceName 服务名称 @param instanceId 实例ID @param healthCheckUrl HTTP健康检查地址 @param instanceHost 服务主机地址 @param instancePort 服务端口号 @param meta 元数据 @param logger 日志对象
type DiscoveryClient ¶
type DiscoveryClient interface { // Register 服务注册接口 // @param serviceName 服务名 // @param instanceId 服务实例Id // @param instancePort 服务实例端口 // @param healthCheckUrl 健康检查地址 // @param instanceHost 服务实例地址 // @param meta 服务实例元数据 Register(serviceName, instanceId, healthCheckUrl string, instanceHost string, instancePort int, meta map[string]string, logger *log.Logger) bool // DeRegister 服务注销接口 // @param instanceId 服务实例Id DeRegister(instanceId string, logger *log.Logger) bool // DiscoverServices 发现服务实例接口 // @param serviceName 服务名 DiscoverServices(serviceName string, logger *log.Logger) []interface{} }
DiscoveryClient 服务发现接口
func NewConsulDiscoverClient ¶
func NewConsulDiscoverClient(consulHost string, consulPort int) (DiscoveryClient, error)
NewConsulDiscoverClient 创建新的Consul客户端 @param consulHost consul主机地址 @param consulPort consul端口号
func NewKitDiscoverClient ¶
func NewKitDiscoverClient(consulHost string, consulPort int) (DiscoveryClient, error)
NewConsulDiscoverClient 创建新的Consul客户端 @param consulHost consul主机地址 @param consulPort consul端口号
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"` // 权重 }
服务实例结构体
type KitDiscoverClient ¶
type KitDiscoverClient struct { Host string // Consul 主机地址 Port int // Consul 端口号 // contains filtered or unexported fields }
func (*KitDiscoverClient) DeRegister ¶
func (consulClient *KitDiscoverClient) DeRegister(instanceId string, logger *log.Logger) bool
DeRegister 注销微服务 @param instanceId 服务ID @param logger 日志对象
func (*KitDiscoverClient) DiscoverServices ¶
func (consulClient *KitDiscoverClient) DiscoverServices(serviceName string, logger *log.Logger) []interface{}
DiscoverServices 发现服务 @param serviceName 服务名称 @param logger 日志对象
func (*KitDiscoverClient) Register ¶
func (consulClient *KitDiscoverClient) Register(serviceName, instanceId, healthCheckUrl string, instanceHost string, instancePort int, meta map[string]string, logger *log.Logger) bool
Register 注册微服务 @param serviceName 服务名称 @param instanceId 实例ID @param healthCheckUrl HTTP健康检查地址 @param instanceHost 服务主机地址 @param instancePort 服务端口号 @param meta 元数据 @param logger 日志对象
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package uuid provides implementation of Universally Unique Identifier (UUID).
|
Package uuid provides implementation of Universally Unique Identifier (UUID). |