etcd

package
v0.0.0-...-355bce0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPeerPort   int    = 2380
	DefaultClientPort int    = 2379
	DefaultScheme     string = "http"
)

Functions

func NewEtcdClient

func NewEtcdClient(leaderEndpoint string) *clientv3.Client

Types

type ClientTransportSecurityInfo

type ClientTransportSecurityInfo struct {

	// Path to the client server TLS cert file.
	CertFile string `yaml:"cert-file,omitempty"`

	// Path to the client server TLS key file.
	KeyFile string `yaml:"key-file,omitempty"`

	// Enable client cert authentication.
	ClientCertAuth bool `yaml:"client-cert-auth,omitempty"`

	// Path to the client server TLS trusted CA cert file.
	TrustedCaFile string `yaml:"trusted-ca-file,omitempty"`

	// Client TLS using generated certificates
	AutoTls bool `yaml:"auto-tls,omitempty"`
}

type ETCD

type ETCD struct {
	Config *EtcdConfig
	Logger *zap.Logger
}

func NewEtcd

func NewEtcd(config *EtcdConfig) (*ETCD, error)

func (*ETCD) AddMemberAsLearner

func (d *ETCD) AddMemberAsLearner(leaderEndpoint string) (*clientv3.MemberAddResponse, error)

func (*ETCD) IsLeader

func (d *ETCD) IsLeader(advertiseClientUrl string) bool

func (*ETCD) Promote

func (d *ETCD) Promote(leaderEndpoint string, memberId uint64) (*clientv3.MemberPromoteResponse, error)

func (*ETCD) RemoveMember

func (d *ETCD) RemoveMember(leaderEndpoint string, nodeName string) error

func (*ETCD) ShowMembers

func (d *ETCD) ShowMembers() ([]EtcdMember, error)

func (*ETCD) StartEtcd

func (d *ETCD) StartEtcd(ctx context.Context, config *EtcdConfig)

type EtcdConfig

type EtcdConfig struct {
	// Human-readable name for this member.
	Name string `yaml:"name,omitempty"`

	// Path to the data directory.
	DataDir string `yaml:"data-dir,omitempty"`

	// Path to the dedicated wal directory.
	WalDir string `yaml:"wal-dir,omitempty"`

	// List of comma separated URLs to listen on for peer traffic.
	ListenPeerUrls string `yaml:"listen-peer-urls,omitempty"`

	// List of comma separated URLs to listen on for client traffic.
	ListenClientUrls string `yaml:"listen-client-urls,omitempty"`

	// List of this member's peer URLs to advertise to the rest of the cluster.
	// The URLs needed to be a comma-separated list.
	InitialAdvertisePeerUrls string `yaml:"initial-advertise-peer-urls,omitempty"`

	// List of this member's client URLs to advertise to the public.
	// The URLs needed to be a comma-separated list.
	AdvertiseClientUrls string `yaml:"advertise-client-urls,omitempty"`

	// Initial cluster configuration for bootstrapping.
	InitialCluster string `yaml:"initial-cluster,omitempty"`

	// Initial cluster token for the etcd cluster during bootstrap.
	InitialClusterToken string `yaml:"initial-cluster-token,omitempty"`

	// Initial cluster state ('new' or 'existing').
	InitialClusterState string `yaml:"initial-cluster-state,omitempty"`

	ClientTransportSecurity ClientTransportSecurityInfo `yaml:"client-transport-security,omitempty"`

	PeerTransportSecurity PeerTransportSecurityInfo `yaml:"peer-transport-security,omitempty"`

	// Enable debug-level logging for etcd.
	Debug bool `yaml:"debug,omitempty"`

	// Maximum number of snapshot files to retain (0 is unlimited).
	MaxSnapshots int `yaml:"max-snapshots,omitempty"`

	// Maximum number of wal files to retain (0 is unlimited).
	MaxWals int `yaml:"max-wals,omitempty"`
}

func LoadEtcdConfig

func LoadEtcdConfig(configPath string) *EtcdConfig

func (*EtcdConfig) ToEmbedEtcdConfig

func (e *EtcdConfig) ToEmbedEtcdConfig() *embed.Config

func (*EtcdConfig) ToFile

func (e *EtcdConfig) ToFile(config string)

type EtcdMember

type EtcdMember struct {
	ClientURLs []string
	IsLearner  bool
	PeerURLs   []string
	ID         uint64
	Name       string
}

type PeerTransportSecurityInfo

type PeerTransportSecurityInfo struct {
	// Path to the peer server TLS cert file.
	CertFile string `yaml:"cert-file,omitempty"`

	// Path to the peer client server TLS key file.
	KeyFile string `yaml:"key-file,omitempty"`

	// Enable peer client cert authentication.
	ClientCertAuth bool `yaml:"client-cert-auth,omitempty"`

	// Path to the peer client server TLS trusted CA cert file.
	TrustedCaFile string `yaml:"trusted-ca-file,omitempty"`

	// Peer TLS using generated certificates
	AutoTls bool `yaml:"auto-tls,omitempty"`
}

Jump to

Keyboard shortcuts

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