etcd

package
v3.35.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0

Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0

Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowCluster

func AllowCluster() bool

allows us to conditionally build an enterprise version of FB that does cluster, in contrast to the PLG version.

Types

type DirCleaner

type DirCleaner interface {
	Cleanup(func())
	Fatalf(string, ...interface{})
	Logf(string, ...interface{})
	Name() string
	TempDir() string
}

DirCleaner represents the subset of the testing.TB interface we care about, allowing us to take objects which behave like that without importing all of testing to get them.

type EmbeddedEtcd

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

func NewEmbeddedEtcd

func NewEmbeddedEtcd(p *Etcd, opts *embed.Config) (*EmbeddedEtcd, error)

func (*EmbeddedEtcd) ID

func (e *EmbeddedEtcd) ID() string

func (*EmbeddedEtcd) IsLeader

func (e *EmbeddedEtcd) IsLeader() bool

func (*EmbeddedEtcd) Leader

func (e *EmbeddedEtcd) Leader() *disco.Peer

func (*EmbeddedEtcd) NewClient

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

func (*EmbeddedEtcd) Peers

func (e *EmbeddedEtcd) Peers() []*disco.Peer

func (*EmbeddedEtcd) Shutdown

func (e *EmbeddedEtcd) Shutdown()

func (*EmbeddedEtcd) Startup

type Etcd

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

func NewEtcd

func NewEtcd(opt Options, logger logger.Logger, replicas int, version string) *Etcd

func (*Etcd) Close

func (e *Etcd) Close() error

Close implements io.Closer

func (*Etcd) ClusterState

func (e *Etcd) ClusterState(ctx context.Context) (out disco.ClusterState, err error)

func (*Etcd) CreateField

func (e *Etcd) CreateField(ctx context.Context, indexName string, name string, fieldVal []byte) error

func (*Etcd) CreateIndex

func (e *Etcd) CreateIndex(ctx context.Context, name string, val []byte) error

func (*Etcd) CreateView

func (e *Etcd) CreateView(ctx context.Context, indexName, fieldName, name string) (err error)

CreateView differs from CreateIndex and CreateField in that it does not return an error if the view already exists. If this logic needs to be changed, we likely need to return disco.ErrViewExists.

func (*Etcd) DeleteField

func (e *Etcd) DeleteField(ctx context.Context, indexName string, name string) (err error)

func (*Etcd) DeleteIndex

func (e *Etcd) DeleteIndex(ctx context.Context, name string) (err error)

func (*Etcd) DeleteNode

func (e *Etcd) DeleteNode(ctx context.Context, nodeID string) error

func (*Etcd) DeleteView

func (e *Etcd) DeleteView(ctx context.Context, indexName, fieldName, name string) error

func (*Etcd) Field

func (e *Etcd) Field(ctx context.Context, indexName string, name string) ([]byte, error)

func (*Etcd) ID

func (e *Etcd) ID() string

func (*Etcd) Index

func (e *Etcd) Index(ctx context.Context, name string) ([]byte, error)

func (*Etcd) IsLeader

func (e *Etcd) IsLeader() bool

func (*Etcd) Leader

func (e *Etcd) Leader() *disco.Peer

func (*Etcd) NodeIDs

func (e *Etcd) NodeIDs() []string

NodeIDs returns the list of node IDs in the etcd cluster.

func (*Etcd) Nodes

func (e *Etcd) Nodes() []*disco.Node

Nodes implements the Noder interface. It returns the sorted list of nodes based on the etcd peers.

func (*Etcd) Peers

func (e *Etcd) Peers() []*disco.Peer

func (*Etcd) PrimaryNodeID

func (e *Etcd) PrimaryNodeID(hasher disco.Hasher) string

PrimaryNodeID implements the Noder interface.

func (*Etcd) Schema

func (e *Etcd) Schema(ctx context.Context) (disco.Schema, error)

func (*Etcd) SetMetadata

func (e *Etcd) SetMetadata(ctx context.Context, node *disco.Node) error

func (*Etcd) SetShards

func (e *Etcd) SetShards(ctx context.Context, index, field string, shards []byte) error

SetShards implements the Sharder interface.

func (*Etcd) SetState

func (e *Etcd) SetState(ctx context.Context, state disco.NodeState) (err error)

func (*Etcd) Shards

func (e *Etcd) Shards(ctx context.Context, index, field string) ([][]byte, error)

Shards implements the Sharder interface.

func (*Etcd) Start

func (e *Etcd) Start(ctx context.Context) (_ disco.InitialClusterState, err error)

Start starts etcd and hearbeat

func (*Etcd) UpdateField

func (e *Etcd) UpdateField(ctx context.Context, indexName string, name string, fieldVal []byte) error

func (*Etcd) View

func (e *Etcd) View(ctx context.Context, indexName, fieldName, name string) (bool, error)

type EtcdServicer

type EtcdServicer interface {
	Shutdown()
	Peers() []*disco.Peer
	IsLeader() bool
	Leader() *disco.Peer
	ID() string
	Startup(ctx context.Context, state disco.InitialClusterState) (disco.InitialClusterState, error)
	NewClient() (*clientv3.Client, error)
}

EtcdServicer provides access to either an embeded etcd server or an external host

type ExternalEtcd

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

func NewExternalEtcd

func NewExternalEtcd(p *Etcd, o Options) (*ExternalEtcd, error)

func (*ExternalEtcd) ID

func (e *ExternalEtcd) ID() string

func (*ExternalEtcd) IsLeader

func (e *ExternalEtcd) IsLeader() bool

TODO this is a nonsense implementation right now will fill out when understand the issue

func (*ExternalEtcd) Leader

func (e *ExternalEtcd) Leader() *disco.Peer

func (*ExternalEtcd) NewClient

func (e *ExternalEtcd) NewClient() (*clientv3.Client, error)

func (*ExternalEtcd) Peers

func (e *ExternalEtcd) Peers() []*disco.Peer

func (*ExternalEtcd) Shutdown

func (e *ExternalEtcd) Shutdown()

func (*ExternalEtcd) Startup

type Options

type Options struct {
	Name         string `toml:"name"`
	Dir          string `toml:"dir"`
	LClientURL   string `toml:"listen-client-url"`
	AClientURL   string `toml:"advertise-client-url"`
	LPeerURL     string `toml:"listen-peer-url"`
	APeerURL     string `toml:"advertise-peer-url"`
	ClusterURL   string `toml:"cluster-url"`
	InitCluster  string `toml:"initial-cluster"`
	ClusterName  string `toml:"cluster-name"`
	HeartbeatTTL int64  `toml:"heartbeat-ttl"`
	// TLS provided tls files
	TrustedCAFile  string `toml:"tls-trusted-cafile"`
	ClientCertFile string `toml:"tls-cert-file"`
	ClientKeyFile  string `toml:"tls-key-file"`
	PeerCertFile   string `toml:"tls-peer-cert-file"`
	PeerKeyFile    string `toml:"tls-peer-key-file"`

	LPeerSocket   []*net.TCPListener
	LClientSocket []*net.TCPListener

	UnsafeNoFsync bool   `toml:"no-fsync"`
	Cluster       string `toml:"static-cluster"`
	EtcdHosts     string `toml:"etcd-hosts"`
	Id            string
}

func GenEtcdConfigs

func GenEtcdConfigs(dc DirCleaner, n int) (clusterName string, cfgs []Options)

GenEtcdConfigs generates a set of etcd configs, and an initial cluster URL. It also makes temporary etcd dirs. Everything it creates is cleaned up by `dc.Cleanup` after the test/benchmark completes. On error, it calls `dc.Fatalf`, presumably terminating the test.

Jump to

Keyboard shortcuts

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