consul

package
v0.0.0-...-d2770bb Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(w http.ResponseWriter, r *http.Request)

Check consul 服务端会自己发送请求,来进行健康检查

func CheckIPAddr

func CheckIPAddr(ip string) error

func LocalIP

func LocalIP() string

func ParseIp

func ParseIp(ip string) string

func RegisterServer

func RegisterServer(info *Info) error

RegisterServer 注册服务的IP和地址

func SearchServer

func SearchServer(info *ClientInfo) (map[string]string, error)

SearchServer 获取 server 注册的 IP和地址

Types

type ClientInfo

type ClientInfo struct {
	Name    string `json:"name"`    // 服务名称
	Tag     string `json:"tag"`     // tag,可以为空
	Address string `json:"address"` // 服务 IP
}

type GRPC

type GRPC struct {
	GIP      string `json:"gIp"`
	GPort    string `json:"gPort"`
	GService string `json:"gService"`
}

type Info

type Info struct {
	ID                             string   `json:"id"`                             // 服务节点的名称
	Name                           string   `json:"name"`                           // 服务名称
	Port                           int      `json:"port"`                           // 服务端口
	Tags                           []string `json:"tags"`                           // tag,可以为空
	Address                        string   `json:"address"`                        // 服务 IP
	ConsulAddress                  string   `json:"consulAddress"`                  // 注册中心 consul 地址
	CheckPort                      int      `json:"checkPort"`                      // 健康检查端口
	CheckTimeout                   string   `json:"Timeout"`                        //
	CheckInterval                  string   `json:"checkInterval"`                  // 健康检查间隔
	DeregisterCriticalServiceAfter string   `json:"deregisterCriticalServiceAfter"` // check失败后30秒删除本服务,注销时间,相当于过期时间
	GRPC                                    // grpc 支持,执行健康检查的地址,service 会传到 Health.Check 函数中
}

Jump to

Keyboard shortcuts

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