consul

package
v0.0.0-...-aed9a31 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(o *Options)

func WithAddr

func WithAddr(addr string) Option

WithAddr 设置客户端连接地址

func WithDeregisterCriticalServiceAfter

func WithDeregisterCriticalServiceAfter(after int) Option

WithDeregisterCriticalServiceAfter 设置健康检测失败后自动注销服务时间

func WithEnableHealthCheck

func WithEnableHealthCheck(enable bool) Option

WithEnableHealthCheck 设置是否启用健康检查

func WithHealthCheckInterval

func WithHealthCheckInterval(interval int) Option

WithHealthCheckInterval 设置健康检查时间间隔

func WithHealthCheckTimeout

func WithHealthCheckTimeout(timeout int) Option

WithHealthCheckTimeout 设置健康检查超时时间

type Options

type Options struct {
	// 客户端连接地址
	// 内建客户端配置,默认为127.0.0.1:8500
	Addr string

	// 是否启用健康检查
	// 默认为true
	EnableHealthCheck bool

	// 健康检查时间间隔(秒),仅在启用健康检查后生效
	// 默认10秒
	HealthCheckInterval int

	// 健康检查超时时间(秒),仅在启用健康检查后生效
	// 默认5秒
	HealthCheckTimeout int

	// 健康检测失败后自动注销服务时间(秒)
	// 默认30秒
	CheckFailedDeregister int
}

type Registry

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

func NewRegistry

func NewRegistry(ctx context.Context, opts ...Option) (*Registry, error)

func (*Registry) Delete

func (r *Registry) Delete(key string) error

func (*Registry) Deregister

func (r *Registry) Deregister(ctx context.Context, ins *discovery.ServiceInstance) error

Deregister 解注册服务实例

func (*Registry) Get

func (r *Registry) Get(key string) ([]byte, error)

func (*Registry) List

func (r *Registry) List(key string) (map[string][]byte, error)

func (*Registry) Register

func (r *Registry) Register(ins *discovery.ServiceInstance) error

Register 注册服务实例

func (*Registry) Services

func (r *Registry) Services(ctx context.Context, serviceName string) ([]*discovery.ServiceInstance, error)

Services 获取服务实例列表

func (*Registry) Set

func (r *Registry) Set(key string, value string) error

func (*Registry) Watch

func (r *Registry) Watch(ctx context.Context, serviceName string, cb func([]*discovery.ServiceInstance)) (discovery.Watcher, error)

Watch 监听服务

Jump to

Keyboard shortcuts

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