etcd

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: PostgreSQL Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMinimumClusterSize = errors.New("cannot remove a member from a cluster with less than three nodes")
	ErrCannotRemoveSelf   = errors.New("cannot remove self from cluster")
	ErrInvalidJoinToken   = errors.New("invalid join token")
)
View Source
var ErrOperationNotSupported = errors.New("operation not supported")

Functions

func Provide

func Provide(i *do.Injector)

func RemoveHost

func RemoveHost(
	ctx context.Context,
	client *clientv3.Client,
	certSvc *certificates.Service,
	hostID string,
) error

func RemoveHostCredentials

func RemoveHostCredentials(
	ctx context.Context,
	client *clientv3.Client,
	certSvc *certificates.Service,
	hostID string,
) error

func RemoveInstanceEtcdUser

func RemoveInstanceEtcdUser(
	ctx context.Context,
	client *clientv3.Client,
	certSvc *certificates.Service,
	instanceID string,
) error

func RemoveMember

func RemoveMember(ctx context.Context, client *clientv3.Client, hostID string) error

func VerifyJoinToken

func VerifyJoinToken(certSvc *certificates.Service, in string) error

Types

type ClusterMember

type ClusterMember struct {
	Name       string
	PeerURLs   []string
	ClientURLs []string
}

func GetClusterLeader

func GetClusterLeader(ctx context.Context, client *clientv3.Client) (*ClusterMember, error)

type EmbeddedEtcd

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

func NewEmbeddedEtcd

func NewEmbeddedEtcd(cfg *config.Manager, logger zerolog.Logger) *EmbeddedEtcd

func (*EmbeddedEtcd) AddHost

func (*EmbeddedEtcd) ClientEndpoints

func (e *EmbeddedEtcd) ClientEndpoints() []string

func (*EmbeddedEtcd) Error

func (e *EmbeddedEtcd) Error() <-chan error

func (*EmbeddedEtcd) GetClient

func (e *EmbeddedEtcd) GetClient() (*clientv3.Client, error)

func (*EmbeddedEtcd) HealthCheck

func (e *EmbeddedEtcd) HealthCheck() common.ComponentStatus

func (*EmbeddedEtcd) Initialized

func (e *EmbeddedEtcd) Initialized() <-chan struct{}

func (*EmbeddedEtcd) IsInitialized

func (e *EmbeddedEtcd) IsInitialized() (bool, error)

func (*EmbeddedEtcd) Join

func (e *EmbeddedEtcd) Join(ctx context.Context, options JoinOptions) error

func (*EmbeddedEtcd) JoinToken

func (e *EmbeddedEtcd) JoinToken() (string, error)

func (*EmbeddedEtcd) Leader

func (e *EmbeddedEtcd) Leader(ctx context.Context) (*ClusterMember, error)

func (*EmbeddedEtcd) PeerEndpoints

func (e *EmbeddedEtcd) PeerEndpoints() []string

func (*EmbeddedEtcd) PromoteWhenReady

func (e *EmbeddedEtcd) PromoteWhenReady(ctx context.Context, client *clientv3.Client, memberName string) error

func (*EmbeddedEtcd) RemoveHost

func (e *EmbeddedEtcd) RemoveHost(ctx context.Context, hostID string) error

func (*EmbeddedEtcd) Shutdown

func (e *EmbeddedEtcd) Shutdown() error

func (*EmbeddedEtcd) Start

func (e *EmbeddedEtcd) Start(ctx context.Context) error

func (*EmbeddedEtcd) VerifyJoinToken

func (e *EmbeddedEtcd) VerifyJoinToken(in string) error

type Etcd

type Etcd interface {
	common.HealthCheckable

	IsInitialized() (bool, error)
	Start(ctx context.Context) error
	Join(ctx context.Context, options JoinOptions) error
	Initialized() <-chan struct{}
	Error() <-chan error
	GetClient() (*clientv3.Client, error)
	Leader(ctx context.Context) (*ClusterMember, error)
	AddHost(ctx context.Context, opts HostCredentialOptions) (*HostCredentials, error)
	RemoveHost(ctx context.Context, hostID string) error
	JoinToken() (string, error)
	VerifyJoinToken(in string) error
}

type HostCredentialOptions

type HostCredentialOptions struct {
	HostID              string
	Hostname            string
	IPv4Address         string
	EmbeddedEtcdEnabled bool
}

type HostCredentials

type HostCredentials struct {
	Username   string
	Password   string
	CaCert     []byte
	ClientCert []byte
	ClientKey  []byte
	ServerCert []byte
	ServerKey  []byte
}

func CreateHostCredentials

func CreateHostCredentials(
	ctx context.Context,
	client *clientv3.Client,
	certSvc *certificates.Service,
	opts HostCredentialOptions,
) (*HostCredentials, error)

type InstanceUserCredentials

type InstanceUserCredentials struct {
	Username   string
	Password   string
	CaCert     []byte
	ClientCert []byte
	ClientKey  []byte
}

func CreateInstanceEtcdUser

func CreateInstanceEtcdUser(
	ctx context.Context,
	client *clientv3.Client,
	certSvc *certificates.Service,
	opts InstanceUserOptions,
) (*InstanceUserCredentials, error)

type InstanceUserOptions

type InstanceUserOptions struct {
	InstanceID string
	KeyPrefix  string
	Password   string
}

type JoinOptions

type JoinOptions struct {
	Leader      *ClusterMember
	Credentials *HostCredentials
}

type RemoteEtcd

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

func NewRemoteEtcd

func NewRemoteEtcd(cfg *config.Manager, logger zerolog.Logger) *RemoteEtcd

func (*RemoteEtcd) AddHost

func (*RemoteEtcd) Error

func (r *RemoteEtcd) Error() <-chan error

func (*RemoteEtcd) GetClient

func (r *RemoteEtcd) GetClient() (*clientv3.Client, error)

func (*RemoteEtcd) HealthCheck

func (r *RemoteEtcd) HealthCheck() common.ComponentStatus

func (*RemoteEtcd) Initialized

func (r *RemoteEtcd) Initialized() <-chan struct{}

func (*RemoteEtcd) IsInitialized

func (r *RemoteEtcd) IsInitialized() (bool, error)

func (*RemoteEtcd) Join

func (r *RemoteEtcd) Join(ctx context.Context, options JoinOptions) error

func (*RemoteEtcd) JoinToken

func (r *RemoteEtcd) JoinToken() (string, error)

func (*RemoteEtcd) Leader

func (r *RemoteEtcd) Leader(ctx context.Context) (*ClusterMember, error)

func (*RemoteEtcd) RemoveHost

func (r *RemoteEtcd) RemoveHost(ctx context.Context, hostID string) error

func (*RemoteEtcd) Shutdown

func (r *RemoteEtcd) Shutdown() error

func (*RemoteEtcd) Start

func (r *RemoteEtcd) Start(ctx context.Context) error

func (*RemoteEtcd) VerifyJoinToken

func (r *RemoteEtcd) VerifyJoinToken(in string) error

Jump to

Keyboard shortcuts

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