consul

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilKV = errors.New("nil kv pair struct")
)

Functions

This section is empty.

Types

type ApiConsulClientI

type ApiConsulClientI interface {
	Agent() *api.Agent
	Health() *api.Health
	KV() *api.KV
	Session() *api.Session
}

ApiConsulClientI - for mocks

type ApiPairs

type ApiPairs = api.KVPairs

type Client

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

Client - custom consul client based on hashicorp client

func New

func New(config Config, log *logger.Logger) (*Client, error)

New - return new custom Consul client

func (*Client) AcquireSessionWithKey

func (c *Client) AcquireSessionWithKey(key string) (bool, error)

AcquireSessionWithKey - acquire session with key in Consul

func (*Client) Addresses

func (c *Client) Addresses(dc string, serviceName string, serviceTags []string) ([]string, error)

Addresses - return list of address

func (*Client) CheckLeadership

func (c *Client) CheckLeadership(oldIsLeader bool, leaderKey string) (isLeader bool, noLeader bool)

CheckLeadership - check leadership (also check not found any leader state)

func (*Client) CreateSession

func (c *Client) CreateSession() (string, error)

CreateSession - create session in Consul

func (*Client) Deregister

func (c *Client) Deregister(logger *logger.Logger, services ...RegistrableService)

Deregister - deregister service in consul

func (*Client) DestroySession

func (c *Client) DestroySession() error

DestroySession - destroy session

func (*Client) IsMySessionIDInKey

func (c *Client) IsMySessionIDInKey(key string) (bool, error)

IsMySessionIDInKey - check is my session in Consul KV

func (*Client) KVGet

func (c *Client) KVGet(key string) ([]byte, error)

KVGet - get key value from Consul

func (*Client) KVPut

func (c *Client) KVPut(key string, value []byte) error

KVPut - put key value into Consul

func (*Client) Register

func (c *Client) Register(logger *logger.Logger, services ...RegistrableService) error

Register - register service in Consul

func (*Client) RenewSession

func (c *Client) RenewSession() error

RenewSession - renew session

func (*Client) RenewSessionPeriodic

func (c *Client) RenewSessionPeriodic(doneChan <-chan struct{}) error

RenewSessionPeriodic - renew session periodic

func (*Client) TryBecomeLeader

func (c *Client) TryBecomeLeader(leaderKey string) (bool, error)

TryBecomeLeader - try to become leader with leader key

type Config

type Config struct {
	Address     string
	Interval    time.Duration
	Timeout     time.Duration
	Tags        []string
	DNS         []string
	SessionTTL  string `yaml:"sessionTTL"`
	WaitTimeout string `yaml:"waitTimeout"`
	// contains filtered or unexported fields
}

Config - cfg for Consul

type RegistrableService

type RegistrableService interface {
	GetConsulServiceRegistration(Config) *Service
}

RegistrableService - interface which need to impl for Consul register

type Service

type Service = api.AgentServiceRegistration

type ServiceCheck

type ServiceCheck = api.AgentServiceCheck

type ServiceChecks

type ServiceChecks = api.AgentServiceChecks

type Services

type Services = []*Service

Jump to

Keyboard shortcuts

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