consul

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client client 封装了 consul 部分读写操作

func NewClient

func NewClient(address string) (*Client, error)

NewClient 传入的 address 应符合 IP:Port 的结构,例如: 127.0.0.1:8080

func (*Client) CheckDeregister

func (bc *Client) CheckDeregister(checkID string) error

CheckDeregister 注销检查器

func (*Client) CheckFail

func (bc *Client) CheckFail(checkID, note string) error

CheckFail 标记状态为 fail

func (*Client) CheckPass

func (bc *Client) CheckPass(checkID, note string) error

CheckPass 标记状态为 pass

func (*Client) CheckRegister

func (bc *Client) CheckRegister(serviceID, checkID string, ttl string) error

CheckRegister 注册检查器

func (*Client) GetOrCreateService

func (bc *Client) GetOrCreateService(serviceID, serviceName string, tags []string, address string, port int) error

func (*Client) ServiceDeregister

func (bc *Client) ServiceDeregister(serviceID string) error

ServiceDeregister 注销 service, name 既是 ID

type Instance

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

Instance 标识一个 Consul 连接实例

func NewConsulInstance

func NewConsulInstance(ctx context.Context, opt InstanceOptions) (*Instance, error)

func (*Instance) CancelService

func (i *Instance) CancelService() error

func (*Instance) CheckDeregister

func (i *Instance) CheckDeregister() error

func (*Instance) CheckPass

func (i *Instance) CheckPass() error

func (*Instance) CheckRegister

func (i *Instance) CheckRegister() error

func (*Instance) DeregisterService

func (i *Instance) DeregisterService() error

func (*Instance) GetOrCreateService

func (i *Instance) GetOrCreateService() error

func (*Instance) KeepServiceAlive

func (i *Instance) KeepServiceAlive() error

func (*Instance) Wait

func (i *Instance) Wait()

type InstanceOptions

type InstanceOptions struct {
	SrvName    string
	Addr       string
	Port       int
	ConsulAddr string
	Tags       []string
	TTL        string
}

Jump to

Keyboard shortcuts

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