discovery

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResponse

type CheckResponse struct {
	Url string

	RetryCount int
	// contains filtered or unexported fields
}

func (*CheckResponse) GetOnTime

func (r *CheckResponse) GetOnTime() int64

func (*CheckResponse) Result

func (r *CheckResponse) Result() string

func (*CheckResponse) SetHealthy

func (r *CheckResponse) SetHealthy(healthy string)

type Config

type Config struct {
	Id                 string
	Name               string
	RegisterAddr       string
	RegisterPort       int
	CheckAddr          string
	CheckPort          int
	Tags               []string
	IntervalTime       int // 健康检查间隔
	DeregisterTime     int //check失败后30秒删除本服务,注销时间,相当于过期时间
	TimeOut            int
	HttpRouter         HttpRouter
	CheckHealthyStatus bool
	CheckResponse      *CheckResponse
	CheckType          string // 检查类型 HTTP TCP GRPC
	CheckPath          string
}

type Discovery

type Discovery interface {
	Register() error
	Deregister() error
}

type HttpRouter

type HttpRouter func(r *CheckResponse)

type KV

type KV interface {
	Get(key string) ([]byte, error)
	Set(key string, value string) error
	Delete(key string) error
	List(key string) (map[string][]byte, error)
}

type Option

type Option func(*Config)

Option for queue system

func WithCheckAddr

func WithCheckAddr(addr string) Option

WithCheckAddr set addr function

func WithCheckGrpc

func WithCheckGrpc(router HttpRouter, checkPath ...string) Option

WithCheckGrpc set checkHttp function r.GET(url, func(c *gin.Context) { c.String(200, "Healthy") })

func WithCheckHTTP

func WithCheckHTTP(router HttpRouter, checkHttp ...string) Option

WithCheckHTTP set checkHttp function r.GET(url, func(c *gin.Context) { c.String(200, "Healthy") })

func WithCheckPort

func WithCheckPort(port int) Option

WithCheckPort set port function

func WithCheckTCP

func WithCheckTCP() Option

WithCheckTCP set checkHttp function r.GET(url, func(c *gin.Context) { c.String(200, "Healthy") })

func WithCheckType

func WithCheckType(checkType string) Option

WithCheckType 检查类型 HTTP TCP GRPC

func WithDeregisterTime

func WithDeregisterTime(deregisterTime int) Option

WithDeregisterTime set deregisterTime function

func WithEnableHealthyStatus

func WithEnableHealthyStatus() Option

WithEnableHealthyStatus checkHealthyStatus function

func WithId

func WithId(id string) Option

WithId set id function

func WithIntervalTime

func WithIntervalTime(intervalTime int) Option

WithIntervalTime set intervalTime function

func WithName

func WithName(name string) Option

WithName set name function

func WithRegisterAddr

func WithRegisterAddr(addr string) Option

WithRegisterAddr set addr function

func WithRegisterPort

func WithRegisterPort(port int) Option

WithRegisterPort set port function

func WithTags

func WithTags(tags ...string) Option

WithTags set tags function

func WithTimeOut

func WithTimeOut(timeOut int) Option

WithTimeOut set timeOut function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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