consul

package
v0.0.0-...-532f4bb Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulClient

type ConsulClient struct {
	// contains filtered or unexported fields
}

func InitConsul

func InitConsul(c *ConsulConfig) (*ConsulClient, error)

func (*ConsulClient) Deregister

func (cli *ConsulClient) Deregister(svcId string) error

func (*ConsulClient) ServiceDeregister

func (cli *ConsulClient) ServiceDeregister() error

服务注销

func (*ConsulClient) ServiceList

func (cli *ConsulClient) ServiceList(svcName string) ([]ServiceInfo, error)

获取服务列表

func (*ConsulClient) ServiceRegister

func (cli *ConsulClient) ServiceRegister(c *RegisterConfig) error

服务注册

type ConsulConfig

type ConsulConfig struct {
	Address string
}

type HealthConfig

type HealthConfig struct {
	HealthType                     string // 健康检查类型 http tcp udp grpc
	HealthUri                      string // 健康检查访问uri
	CheckID                        string // 健康检查唯一id
	Interval                       string // 时间间隔 5s
	Timeout                        string // 超时时间 1s
	DeregisterCriticalServiceAfter string // 超过多少时间注销服务
}

type RegisterConfig

type RegisterConfig struct {
	SvcId   string // 服务id
	SvcName string // 服务名称
	Address string // 服务ip
	Port    int    // 服务端口
	// contains filtered or unexported fields
}

type ServiceInfo

type ServiceInfo struct {
	Ip   string
	Port int
}

Jump to

Keyboard shortcuts

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