etcd

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDialTimeoutSec is the default dial timeout of etcd connection.
	DefaultDialTimeoutSec = 5

	// DefaultLockLeaseTimeSec is the default lease time of lock.
	DefaultLockLeaseTimeSec = 30
)

Variables

This section is empty.

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, agentInfo *sync.AgentInfo) (*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 added in v0.1.5

func (c *Client) Initialize() error

Initialize put this agent to etcd with TTL periodically.

func (*Client) Members added in v0.1.5

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

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 added in v0.1.5

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

Publish publishes the given event to the given Topic.

func (*Client) PublishToLocal added in v0.1.6

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

PublishToLocal publishes the given event to the given Topic.

func (*Client) Subscribe added in v0.1.5

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

Subscribe subscribes to the given topics.

func (*Client) Unsubscribe added in v0.1.5

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

Unsubscribe unsubscribes the given topics.

type Config

type Config struct {
	Endpoints      []string      `json:"Endpoints"`
	DialTimeoutSec time.Duration `json:"DialTimeoutSec"`
	Username       string        `json:"Username"`
	Password       string        `json:"Password"`

	LockLeaseTimeSec int `json:"LockLeaseTimeSec"`
}

Config is the configuration for creating a Client instance.

Jump to

Keyboard shortcuts

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