consul

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client added in v0.1.4

func Client() *api.Client

Client 客户端连接对象

func ClientID added in v0.1.5

func ClientID() string

ClientID 客户端唯一编号

func Deregister

func Deregister()

Deregister 反注册

func Init

func Init(address string)

Init 初始化服务注册

func Register

func Register(config *RegisterConfig)

Register 注册到consul

func RegisterGRPC added in v0.1.3

func RegisterGRPC(config *RegisterConfig, svc *grpc.Server)

RegisterGRPC GRPC方式注册到consul

Types

type HealthImpl added in v0.1.7

type HealthImpl struct{}

HealthImpl 健康检查实现

func (*HealthImpl) Check added in v0.1.7

Check 实现健康检查接口,这里直接返回健康状态,这里也可以有更复杂的健康检查策略,比如根据服务器负载来返回

func (*HealthImpl) Watch added in v0.1.7

Watch 流式检测

type RegisterConfig

type RegisterConfig struct {
	ServiceName                    string        // 服务显示名称
	ServiceAddress                 string        // consul IP地址
	ServicePort                    int           // 端口
	Tags                           []string      // 标签
	Interval                       time.Duration // 健康检查时间间隔(单位秒)
	DeregisterCriticalServiceAfter time.Duration
}

RegisterConfig consul注册配置

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL