embed

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config defines the embed etcd

func NewConfig

func NewConfig(name string, clientURLs, peerURLs, endpoints types.URLs, opts ...Option) *Config

NewConfig creates an instance of Config

func (*Config) ClientURLs

func (c *Config) ClientURLs() types.URLs

ClientURLs returns the client URLs

func (*Config) DataDir

func (c *Config) DataDir() string

DataDir returns the data directory name

func (*Config) EnableLogging

func (c *Config) EnableLogging() bool

func (*Config) EndPoints

func (c *Config) EndPoints() types.URLs

EndPoints returns the endpoints

func (*Config) InitialCluster

func (c *Config) InitialCluster() string

InitialCluster returns the endpoints

func (*Config) LogDir

func (c *Config) LogDir() string

LogDir returns the log directory

func (*Config) Logger

func (c *Config) Logger() log.Logger

Logger returns the configured logger

func (*Config) Name

func (c *Config) Name() string

Name returns the name

func (*Config) PeerURLs

func (c *Config) PeerURLs() types.URLs

PeerURLs returns the peer URLs

func (*Config) StartTimeout

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

StartTimeout returns the start timeout

type Node

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

Node embeds a etcd server

func NewNode

func NewNode(config *Config) *Node

NewNode creates an instance of Node

func (*Node) Client

func (n *Node) Client() *clientv3.Client

Client returns the etcd client of Embed

func (*Node) ClientURLs

func (n *Node) ClientURLs() types.URLs

ClientURLs returns the list of client endpoint

func (*Node) ID

func (n *Node) ID() string

ID returns the given node id

func (*Node) IsLeader

func (n *Node) IsLeader() bool

IsLeader states whether the given node is a leader or not

func (*Node) LeaderID

func (n *Node) LeaderID() string

LeaderID returns the leader id

func (*Node) Members

func (n *Node) Members() ([]*etcdserverpb.Member, error)

Members returns the given node members

func (*Node) RemoveMember

func (n *Node) RemoveMember(member *etcdserverpb.Member) error

RemoveMember removes a given member from the memberlist

func (*Node) Session

func (n *Node) Session() *concurrency.Session

Session returns the etcd session used by Embed

func (*Node) Start

func (n *Node) Start() error

Start starts the underlying etcd server

func (*Node) Stop

func (n *Node) Stop() error

Stop stops the Node instance

func (*Node) UpdateMember

func (n *Node) UpdateMember(member *etcdserverpb.Member) error

UpdateMember updates a given member

type Option

type Option interface {
	// Apply sets the Option value of a config.
	Apply(config *Config)
}

Option is the interface that applies a configuration option.

func WithDataDir

func WithDataDir(datadir string) Option

WithDataDir sets the data dir

func WithInitialCluster

func WithInitialCluster(initialCluster string) Option

WithInitialCluster sets the initial cluster

func WithJoin

func WithJoin(join bool) Option

WithJoin sets join field to true and tells the node to join an existing cluster

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger

func WithLoggingEnable

func WithLoggingEnable() Option

WithLoggingEnable enables logging

func WithStartTimeout

func WithStartTimeout(timeout time.Duration) Option

WithStartTimeout sets the start timeout

type OptionFunc

type OptionFunc func(config *Config)

OptionFunc implements the Option interface.

func (OptionFunc) Apply

func (f OptionFunc) Apply(c *Config)

Jump to

Keyboard shortcuts

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