Documentation ¶
Index ¶
- Constants
- func NewPackageStats(now time.Time, size int) *packageStats
- type Config
- 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) LoadMachineFile() error
- func (c *Config) LoadSystemFile() error
- 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, url string) error
- func (r *Registry) Unregister(name string) error
- type RemoveCommand
- type Server
- func (s *Server) AllowOrigins(origins []string) error
- 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) GetMachinesHandler(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 ( // The amount of time to elapse without a heartbeat before becoming a candidate. ElectionTimeout = 200 * time.Millisecond // The frequency by which heartbeats are sent to followers. HeartbeatTimeout = 50 * time.Millisecond RetryInterval = 10 )
const DefaultSystemConfigPath = "/etc/etcd/etcd.conf"
The default location for the etcd configuration file.
const RegistryKey = "/_etcd/machines"
The location of the machine 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 AdvertisedUrl string `toml:"advertised_url" env:"ETCD_ADVERTISED_URL"` CAFile string `toml:"ca_file" env:"ETCD_CA_FILE"` CertFile string `toml:"cert_file" env:"ETCD_CERT_FILE"` Cors []string `toml:"cors" env:"ETCD_CORS"` DataDir string `toml:"datadir" env:"ETCD_DATADIR"` KeyFile string `toml:"key_file" env:"ETCD_KEY_FILE"` ListenHost string `toml:"listen_host" env:"ETCD_LISTEN_HOST"` Machines []string `toml:"machines" env:"ETCD_MACHINES"` MachinesFile string `toml:"machines_file" env:"ETCD_MACHINES_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"` SnapCount int `toml:"snapshot_count" env:"ETCD_SNAPSHOTCOUNT"` Verbose bool `toml:"verbose" env:"ETCD_VERBOSE"` VeryVerbose bool `toml:"very_verbose" env:"ETCD_VERY_VERBOSE"` WebURL string `toml:"web_url" env:"ETCD_WEB_URL"` Peer struct { AdvertisedUrl string `toml:"advertised_url" env:"ETCD_PEER_ADVERTISED_URL"` 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"` ListenHost string `toml:"listen_host" env:"ETCD_PEER_LISTEN_HOST"` } }
Config represents the server configuration.
func NewConfig ¶
func NewConfig() *Config
NewConfig returns a Config initialized with default values.
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) LoadMachineFile ¶
LoadMachineFile loads the machines listed in the machine file.
func (*Config) LoadSystemFile ¶
Loads from the system etcd configuration file if it exists.
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"` WebURL string `json:"webURL"` 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 // 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, listenHost string, tlsConf *TLSConfig, tlsInfo *TLSInfo, peerServer *PeerServer, registry *Registry, store store.Store) *Server
Creates a new Server.
func (*Server) 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) GetMachinesHandler ¶
Handler to return all the known machines 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 ¶
Determines whether the server will allow a given CORS origin.
func (*Server) SpeedTestHandler ¶
Executes a speed test to evaluate the performance of update replication.