Documentation ¶
Overview ¶
Package embed provides bindings for embedding an etcd server in a program.
Launch an embedded etcd server using the configuration defaults:
import ( "log" "github.com/coreos/etcd/embed" ) func main() { cfg := embed.NewConfig() cfg.Dir = "default.etcd" e, err := embed.StartEtcd(cfg) if err != nil { log.Fatal(err) } defer e.Close() log.Fatal(<-e.Err()) }
Index ¶
Constants ¶
View Source
const ( ClusterStateFlagNew = "new" ClusterStateFlagExisting = "existing" DefaultName = "default" DefaultInitialAdvertisePeerURLs = "http://localhost:2380" DefaultAdvertiseClientURLs = "http://localhost:2379" DefaultListenPeerURLs = "http://localhost:2380" DefaultListenClientURLs = "http://localhost:2379" DefaultMaxSnapshots = 5 DefaultMaxWALs = 5 )
Variables ¶
View Source
var ( ErrConflictBootstrapFlags = fmt.Errorf("multiple discovery or bootstrap flags are set. " + "Choose one of \"initial-cluster\", \"discovery\" or \"discovery-srv\"") ErrUnsetAdvertiseClientURLsFlag = fmt.Errorf("--advertise-client-urls is required when --listen-client-urls is set explicitly") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { CorsInfo *cors.CORSInfo LPUrls, LCUrls []url.URL Dir string `json:"data-dir"` WalDir string `json:"wal-dir"` MaxSnapFiles uint `json:"max-snapshots"` MaxWalFiles uint `json:"max-wals"` Name string `json:"name"` SnapCount uint64 `json:"snapshot-count"` AutoCompactionRetention int `json:"auto-compaction-retention"` // TickMs is the number of milliseconds between heartbeat ticks. // TODO: decouple tickMs and heartbeat tick (current heartbeat tick = 1). // make ticks a cluster wide configuration. TickMs uint `json:"heartbeat-interval"` ElectionMs uint `json:"election-timeout"` QuotaBackendBytes int64 `json:"quota-backend-bytes"` APUrls, ACUrls []url.URL ClusterState string `json:"initial-cluster-state"` DNSCluster string `json:"discovery-srv"` Dproxy string `json:"discovery-proxy"` Durl string `json:"discovery"` InitialCluster string `json:"initial-cluster"` InitialClusterToken string `json:"initial-cluster-token"` StrictReconfigCheck bool `json:"strict-reconfig-check"` ClientTLSInfo transport.TLSInfo ClientAutoTLS bool PeerTLSInfo transport.TLSInfo PeerAutoTLS bool Debug bool `json:"debug"` LogPkgLevels string `json:"log-package-levels"` EnablePprof bool // ForceNewCluster starts a new cluster even if previously started; unsafe. ForceNewCluster bool `json:"force-new-cluster"` }
Config holds the arguments for configuring an etcd server.
func ConfigFromFile ¶
func NewConfig ¶
func NewConfig() *Config
NewConfig creates a new Config populated with default values.
func (Config) ElectionTicks ¶
func (Config) InitialClusterFromName ¶
func (Config) IsNewCluster ¶
type Etcd ¶
type Etcd struct { Peers []net.Listener Clients []net.Listener Server *etcdserver.EtcdServer // contains filtered or unexported fields }
Etcd contains a running etcd server and its listeners.
Click to show internal directories.
Click to hide internal directories.