Documentation ¶
Index ¶
- Constants
- func NewPackageStats(now time.Time, size int) *packageStats
- func Usage() string
- type Config
- func (c *Config) DataDirFromName()
- func (c *Config) Info() (*Info, error)
- func (c *Config) Load(arguments []string) error
- func (c *Config) LoadEnv() error
- func (c *Config) LoadFile(path string) error
- func (c *Config) LoadFlags(arguments []string) error
- func (c *Config) LoadPeersFile() error
- func (c *Config) LoadSystemFile() error
- func (c *Config) NameFromHostname()
- func (c *Config) PeerTLSConfig() (TLSConfig, error)
- func (c *Config) PeerTLSInfo() TLSInfo
- func (c *Config) Reset() error
- func (c *Config) Sanitize() error
- func (c *Config) TLSConfig() (TLSConfig, error)
- func (c *Config) TLSInfo() TLSInfo
- type Info
- type JoinCommand
- type PeerServer
- func (ps *PeerServer) AppendEntriesHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) Close()
- func (ps *PeerServer) EtcdURLHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) GetLogHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) JoinHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) ListenAndServe(snapshot bool, cluster []string) error
- func (ps *PeerServer) NameHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) PeerStats() []byte
- func (s *PeerServer) RaftServer() raft.Server
- func (ps *PeerServer) RemoveHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) SetServer(server *Server)
- func (ps *PeerServer) SnapshotHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) SnapshotRecoveryHttpHandler(w http.ResponseWriter, req *http.Request)
- func (s *PeerServer) Stats() []byte
- func (s *PeerServer) Upgradable() error
- func (ps *PeerServer) UpgradeHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) VersionCheckHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) VersionHttpHandler(w http.ResponseWriter, req *http.Request)
- func (ps *PeerServer) VoteHttpHandler(w http.ResponseWriter, req *http.Request)
- type Registry
- func (r *Registry) ClientURL(name string) (string, bool)
- func (r *Registry) ClientURLs(leaderName, selfName string) []string
- func (r *Registry) Count() int
- func (r *Registry) Invalidate(name string)
- func (r *Registry) PeerURL(name string) (string, bool)
- func (r *Registry) PeerURLs(leaderName, selfName string) []string
- func (r *Registry) Register(name string, peerURL string, machURL string) error
- func (r *Registry) Unregister(name string) error
- type RemoveCommand
- type Server
- func (s *Server) AllowOrigins(origins []string) error
- func (s *Server) ClientURL(name string) (string, bool)
- func (s *Server) Close()
- func (s *Server) CommitIndex() uint64
- func (s *Server) Dispatch(c raft.Command, w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetLeaderHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetLeaderStatsHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetPeersHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetStatsHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetStoreStatsHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) GetVersionHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) Leader() string
- func (s *Server) ListenAndServe() error
- func (s *Server) OriginAllowed(origin string) bool
- func (s *Server) PeerURL(name string) (string, bool)
- func (s *Server) SpeedTestHandler(w http.ResponseWriter, req *http.Request) error
- func (s *Server) State() string
- func (s *Server) Store() store.Store
- func (s *Server) Term() uint64
- func (s *Server) URL() string
- type TLSConfig
- type TLSInfo
Constants ¶
const DefaultSystemConfigPath = "/etc/etcd/etcd.conf"
The default location for the etcd configuration file.
const RegistryKey = "/_etcd/machines"
The location of the peer URL data.
const Version = "v2"
Variables ¶
This section is empty.
Functions ¶
func NewPackageStats ¶
NewPackageStats creates a pacakgeStats and return the pointer to it.
Types ¶
type Config ¶
type Config struct { SystemPath string Addr string `toml:"addr" env:"ETCD_ADDR"` BindAddr string `toml:"bind_addr" env:"ETCD_BIND_ADDR"` CAFile string `toml:"ca_file" env:"ETCD_CA_FILE"` CertFile string `toml:"cert_file" env:"ETCD_CERT_FILE"` CPUProfileFile string CorsOrigins []string `toml:"cors" env:"ETCD_CORS"` DataDir string `toml:"data_dir" env:"ETCD_DATA_DIR"` Force bool KeyFile string `toml:"key_file" env:"ETCD_KEY_FILE"` Peers []string `toml:"peers" env:"ETCD_PEERS"` PeersFile string `toml:"peers_file" env:"ETCD_PEERS_FILE"` MaxClusterSize int `toml:"max_cluster_size" env:"ETCD_MAX_CLUSTER_SIZE"` MaxResultBuffer int `toml:"max_result_buffer" env:"ETCD_MAX_RESULT_BUFFER"` MaxRetryAttempts int `toml:"max_retry_attempts" env:"ETCD_MAX_RETRY_ATTEMPTS"` Name string `toml:"name" env:"ETCD_NAME"` Snapshot bool `toml:"snapshot" env:"ETCD_SNAPSHOT"` SnapshotCount int `toml:"snapshot_count" env:"ETCD_SNAPSHOTCOUNT"` ShowHelp bool ShowVersion bool Verbose bool `toml:"verbose" env:"ETCD_VERBOSE"` VeryVerbose bool `toml:"very_verbose" env:"ETCD_VERY_VERBOSE"` HeartbeatTimeout int `toml:"peer_heartbeat_timeout" env:"ETCD_PEER_HEARTBEAT_TIMEOUT"` ElectionTimeout int `toml:"peer_election_timeout" env:"ETCD_PEER_ELECTION_TIMEOUT"` Peer struct { Addr string `toml:"addr" env:"ETCD_PEER_ADDR"` BindAddr string `toml:"bind_addr" env:"ETCD_PEER_BIND_ADDR"` CAFile string `toml:"ca_file" env:"ETCD_PEER_CA_FILE"` CertFile string `toml:"cert_file" env:"ETCD_PEER_CERT_FILE"` KeyFile string `toml:"key_file" env:"ETCD_PEER_KEY_FILE"` } }
Config represents the server configuration.
func NewConfig ¶
func NewConfig() *Config
NewConfig returns a Config initialized with default values.
func (*Config) DataDirFromName ¶
func (c *Config) DataDirFromName()
DataDirFromName sets the data dir from a machine name and issue a warning that etcd is guessing.
func (*Config) Info ¶
Reads the info file from the file system or initializes it based on the config.
func (*Config) Load ¶
Loads the configuration from the system config, command line config, environment variables, and finally command line arguments.
func (*Config) LoadPeersFile ¶
LoadPeersFile loads the peers listed in the peers file.
func (*Config) LoadSystemFile ¶
Loads from the system etcd configuration file if it exists.
func (*Config) NameFromHostname ¶
func (c *Config) NameFromHostname()
NameFromHostname sets the machine name from the hostname. This is to help people get started without thinking up a name.
func (*Config) PeerTLSConfig ¶
PeerTLSConfig generates the TLS configuration for the peer server.
func (*Config) PeerTLSInfo ¶
PeerTLSInfo retrieves a TLSInfo object for the peer server.
type Info ¶
type Info struct { Name string `json:"name"` RaftURL string `json:"raftURL"` EtcdURL string `json:"etcdURL"` RaftListenHost string `json:"raftListenHost"` EtcdListenHost string `json:"etcdListenHost"` RaftTLS TLSInfo `json:"raftTLS"` EtcdTLS TLSInfo `json:"etcdTLS"` }
Info describes the non-mutable state of the server upon initialization. These fields cannot be changed without deleting the server fields and reinitializing.
type JoinCommand ¶
type JoinCommand struct { MinVersion int `json:"minVersion"` MaxVersion int `json:"maxVersion"` Name string `json:"name"` RaftURL string `json:"raftURL"` EtcdURL string `json:"etcdURL"` }
The JoinCommand adds a node to the cluster.
func NewJoinCommand ¶
func NewJoinCommand(minVersion int, maxVersion int, name, raftUrl, etcdUrl string) *JoinCommand
func (*JoinCommand) Apply ¶
func (c *JoinCommand) Apply(server raft.Server) (interface{}, error)
Join a server to the cluster
func (*JoinCommand) CommandName ¶
func (c *JoinCommand) CommandName() string
The name of the join command in the log
func (*JoinCommand) NodeName ¶
func (c *JoinCommand) NodeName() string
type PeerServer ¶
type PeerServer struct { MaxClusterSize int RetryTimes int HeartbeatTimeout time.Duration ElectionTimeout time.Duration // contains filtered or unexported fields }
func NewPeerServer ¶
func (*PeerServer) AppendEntriesHttpHandler ¶
func (ps *PeerServer) AppendEntriesHttpHandler(w http.ResponseWriter, req *http.Request)
Response to append entries request
func (*PeerServer) EtcdURLHttpHandler ¶
func (ps *PeerServer) EtcdURLHttpHandler(w http.ResponseWriter, req *http.Request)
Get the port that listening for etcd connecting of the server
func (*PeerServer) GetLogHttpHandler ¶
func (ps *PeerServer) GetLogHttpHandler(w http.ResponseWriter, req *http.Request)
Get all the current logs
func (*PeerServer) JoinHttpHandler ¶
func (ps *PeerServer) JoinHttpHandler(w http.ResponseWriter, req *http.Request)
Response to the join request
func (*PeerServer) ListenAndServe ¶
func (s *PeerServer) ListenAndServe(snapshot bool, cluster []string) error
Start the raft server
func (*PeerServer) NameHttpHandler ¶
func (ps *PeerServer) NameHttpHandler(w http.ResponseWriter, req *http.Request)
Response to the name request
func (*PeerServer) PeerStats ¶
func (s *PeerServer) PeerStats() []byte
func (*PeerServer) RaftServer ¶
func (s *PeerServer) RaftServer() raft.Server
Retrieves the underlying Raft server.
func (*PeerServer) RemoveHttpHandler ¶
func (ps *PeerServer) RemoveHttpHandler(w http.ResponseWriter, req *http.Request)
Response to remove request
func (*PeerServer) SetServer ¶
func (s *PeerServer) SetServer(server *Server)
Associates the client server with the peer server.
func (*PeerServer) SnapshotHttpHandler ¶
func (ps *PeerServer) SnapshotHttpHandler(w http.ResponseWriter, req *http.Request)
Response to recover from snapshot request
func (*PeerServer) SnapshotRecoveryHttpHandler ¶
func (ps *PeerServer) SnapshotRecoveryHttpHandler(w http.ResponseWriter, req *http.Request)
Response to recover from snapshot request
func (*PeerServer) Stats ¶
func (s *PeerServer) Stats() []byte
func (*PeerServer) Upgradable ¶
func (s *PeerServer) Upgradable() error
Upgradable checks whether all peers in a cluster support an upgrade to the next store version.
func (*PeerServer) UpgradeHttpHandler ¶
func (ps *PeerServer) UpgradeHttpHandler(w http.ResponseWriter, req *http.Request)
Upgrades the current store version to the next version.
func (*PeerServer) VersionCheckHttpHandler ¶
func (ps *PeerServer) VersionCheckHttpHandler(w http.ResponseWriter, req *http.Request)
Checks whether a given version is supported.
func (*PeerServer) VersionHttpHandler ¶
func (ps *PeerServer) VersionHttpHandler(w http.ResponseWriter, req *http.Request)
Response to the name request
func (*PeerServer) VoteHttpHandler ¶
func (ps *PeerServer) VoteHttpHandler(w http.ResponseWriter, req *http.Request)
Response to vote request
type Registry ¶
The Registry stores URL information for nodes.
func (*Registry) ClientURLs ¶
Retrieves the Client URLs for all nodes.
func (*Registry) Invalidate ¶
Removes a node from the cache.
func (*Registry) Unregister ¶
Removes a node from the registry.
type RemoveCommand ¶
type RemoveCommand struct {
Name string `json:"name"`
}
The RemoveCommand removes a server from the cluster.
func (*RemoveCommand) Apply ¶
func (c *RemoveCommand) Apply(server raft.Server) (interface{}, error)
Remove a server from the cluster
func (*RemoveCommand) CommandName ¶
func (c *RemoveCommand) CommandName() string
The name of the remove command in the log
type Server ¶
This is the default implementation of the Server interface.
func New ¶
func New(name string, urlStr string, bindAddr string, tlsConf *TLSConfig, tlsInfo *TLSInfo, peerServer *PeerServer, registry *Registry, store store.Store) *Server
Creates a new Server.
func (*Server) AllowOrigins ¶
AllowOrigins sets a comma-delimited list of origins that are allowed.
func (*Server) CommitIndex ¶
The current Raft committed index.
func (*Server) GetLeaderHandler ¶
Handler to return the current leader's raft address
func (*Server) GetLeaderStatsHandler ¶
Retrieves stats on the leader.
func (*Server) GetPeersHandler ¶
Handler to return all the known peers in the current cluster.
func (*Server) GetStatsHandler ¶
Retrieves stats on the Raft server.
func (*Server) GetStoreStatsHandler ¶
Retrieves stats on the leader.
func (*Server) GetVersionHandler ¶
Handler to return the current version of etcd.
func (*Server) ListenAndServe ¶
Start to listen and response etcd client command
func (*Server) OriginAllowed ¶
OriginAllowed determines whether the server will allow a given CORS origin.
func (*Server) SpeedTestHandler ¶
Executes a speed test to evaluate the performance of update replication.