etcd

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDialTimeout is the default dial timeout of etcd connection.
	DefaultDialTimeout = 5 * time.Second

	// DefaultLockLeaseTime is the default lease time of lock.
	DefaultLockLeaseTime = 30 * time.Second
)

Variables

View Source
var (
	//ErrEmptyEndpoints occurs when the endpoints in the config is empty.
	ErrEmptyEndpoints = errors.New("length of etcd endpoints must be greater than 0")
)

Functions

This section is empty.

Types

type Client

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

Client is a client that connects to ETCD.

func Dial

func Dial(
	conf *Config,
	serverInfo *sync.ServerInfo,
) (
	*Client, error)

Dial creates a new instance of Client and dials the given ETCD.

func (*Client) Close

func (c *Client) Close() error

Close all resources of this client.

func (*Client) Dial

func (c *Client) Dial() error

Dial dials the given ETCD.

func (*Client) Initialize

func (c *Client) Initialize() error

Initialize put this server to etcd with TTL periodically.

func (*Client) Members

func (c *Client) Members() map[string]*sync.ServerInfo

Members returns the members of this cluster.

func (*Client) NewLocker

func (c *Client) NewLocker(
	ctx context.Context,
	key sync.Key,
) (sync.Locker, error)

NewLocker creates locker of the given key.

func (*Client) Publish

func (c *Client) Publish(
	ctx context.Context,
	publisherID *time.ActorID,
	event sync.DocEvent,
)

Publish publishes the given event.

func (*Client) PublishToLocal

func (c *Client) PublishToLocal(
	ctx context.Context,
	publisherID *time.ActorID,
	event sync.DocEvent,
)

PublishToLocal publishes the given event.

func (*Client) Subscribe

func (c *Client) Subscribe(
	ctx context.Context,
	subscriber types.Client,
	keys []key.Key,
) (*sync.Subscription, map[string][]types.Client, error)

Subscribe subscribes to the given keys.

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(
	ctx context.Context,
	keys []key.Key,
	sub *sync.Subscription,
) error

Unsubscribe unsubscribes the given keys.

func (*Client) UpdatePresence

func (c *Client) UpdatePresence(
	ctx context.Context,
	publisher *types.Client,
	keys []key.Key,
) (*sync.DocEvent, error)

UpdatePresence updates the presence of the given client.

type Config

type Config struct {
	Endpoints   []string `yaml:"Endpoints"`
	DialTimeout string   `yaml:"DialTimeout"`
	Username    string   `yaml:"Username"`
	Password    string   `yaml:"Password"`

	LockLeaseTime string `yaml:"LockLeaseTime"`
}

Config is the configuration for creating a Client instance.

func (*Config) ParseDialTimeout

func (c *Config) ParseDialTimeout() time.Duration

ParseDialTimeout returns timeout for lock.

func (*Config) ParseLockLeaseTime

func (c *Config) ParseLockLeaseTime() time.Duration

ParseLockLeaseTime returns lease time for lock.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates this config.

Jump to

Keyboard shortcuts

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