etcd

package
v0.0.0-...-118e354 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 8 Imported by: 1

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 represents an etcd client.

func New

func New(key string, cfg *Config) (*Client, error)

New returns an instantiated etcd client. If cfg is nil, use the default config.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) GetLeader

func (c *Client) GetLeader() (id string, apiAddr string, addr string, ok bool, e error)

GetLeader returns the leader as recorded in Consul. If a leader exists, ok will be set to true, false otherwise.

func (*Client) InitializeLeader

func (c *Client) InitializeLeader(id, apiAddr, addr string) (bool, error)

InitializeLeader sets the leader to the given details, but only if no leader has already been set. This operation is a check-and-set type operation. If initialization succeeds, ok is set to true.

func (*Client) SetLeader

func (c *Client) SetLeader(id, apiAddr, addr string) error

SetLeader unconditionally sets the leader to the given details.

func (*Client) String

func (c *Client) String() string

String implements the Stringer interface.

type Config

type Config clientv3.Config

Config stores the configuration for the etcd client. The full definition is available at https://pkg.go.dev/go.etcd.io/etcd/clientv3#Config

func NewConfigFromFile

func NewConfigFromFile(path string) (*Config, error)

NewConfigFromFile parses the file at path and returns a Config.

func NewConfigFromReader

func NewConfigFromReader(r io.Reader) (*Config, error)

NewConfigFromReader parses the data returned by the reader and returns a Config. A nil reader results in a nil config.

Jump to

Keyboard shortcuts

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