Documentation
¶
Overview ¶
Package cluster manages etcd cluster.
Index ¶
- type Cluster
- func (clus *Cluster) ActiveNodeN() (cnt int)
- func (clus *Cluster) Add() error
- func (clus *Cluster) AllConfigs() []embed.Config
- func (clus *Cluster) AllEndpoints(scheme bool) []string
- func (clus *Cluster) AllMemberStatus() []clusterpb.MemberStatus
- func (clus *Cluster) Client(eps ...string) (*clientv3.Client, *tls.Config, error)
- func (clus *Cluster) Config(i int) embed.Config
- func (clus *Cluster) Endpoints(i int, scheme bool) []string
- func (clus *Cluster) FindIndex(ep string) int
- func (clus *Cluster) InitialCluster() string
- func (clus *Cluster) IsStopped(i int) (stopped bool)
- func (clus *Cluster) MemberStatus(i int) clusterpb.MemberStatus
- func (clus *Cluster) Quorum() int
- func (clus *Cluster) Remove(i int) error
- func (clus *Cluster) Restart(i int) error
- func (clus *Cluster) SetClientDialTimeout(d time.Duration)
- func (clus *Cluster) Shutdown()
- func (clus *Cluster) Size() int
- func (clus *Cluster) Stop(i int)
- func (clus *Cluster) StopNotify() <-chan struct{}
- func (clus *Cluster) StoppedStartedAt(i int) time.Time
- func (clus *Cluster) UpdateMemberStatus()
- func (clus *Cluster) WaitForLeader() error
- type Config
- type Member
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
Started time.Time
LeadIdx int
Members []*Member
// contains filtered or unexported fields
}
Cluster contains all embedded etcd Members in the same cluster. Configuration is meant to be auto-generated.
func (*Cluster) ActiveNodeN ¶
ActiveNodeN returns the number of Members that are running.
func (*Cluster) AllConfigs ¶
AllConfigs returns all configurations.
func (*Cluster) AllEndpoints ¶
AllEndpoints returns all endpoints of clients.
func (*Cluster) AllMemberStatus ¶
func (clus *Cluster) AllMemberStatus() []clusterpb.MemberStatus
AllMemberStatus returns all node status.
func (*Cluster) Client ¶
Client creates the client.
func (*Cluster) Config ¶
Config returns the configuration of the server.
func (*Cluster) Endpoints ¶
Endpoints returns the endpoints of the node.
func (*Cluster) FindIndex ¶
FindIndex returns the node index by client URL. It returns -1 if none.
func (*Cluster) InitialCluster ¶
InitialCluster returns the 'initial-cluster' string.
func (*Cluster) IsStopped ¶
IsStopped returns true if the node has stopped.
func (*Cluster) MemberStatus ¶
func (clus *Cluster) MemberStatus(i int) clusterpb.MemberStatus
MemberStatus returns the node status.
func (*Cluster) Remove ¶
Remove removes the member and its data.
func (*Cluster) SetClientDialTimeout ¶
SetClientDialTimeout sets the client dial timeout.
func (*Cluster) Shutdown ¶
func (clus *Cluster) Shutdown()
Shutdown stops all Members and deletes all data directories.
func (*Cluster) StopNotify ¶
func (clus *Cluster) StopNotify() <-chan struct{}
StopNotify returns receive-only stop channel to notify the cluster has stopped.
func (*Cluster) StoppedStartedAt ¶
StoppedStartedAt returns the node's last stop and (re)start action time.
type Config ¶
type Config struct {
Size int
RootDir string
RootPort int
EmbeddedClient bool
PeerTLSInfo transport.TLSInfo
PeerAutoTLS bool
ClientTLSInfo transport.TLSInfo
ClientAutoTLS bool
RootCtx context.Context
RootCancel func()
DialTimeout time.Duration // for client requests
}
Config defines etcd local cluster Configuration.
func (Config) ClientScheme ¶
ClientScheme returns the client scheme. TODO: support unix
type Member ¶
type Member struct {
// contains filtered or unexported fields
}
Member contains *embed.Etcd and its state.
func (*Member) Client ¶
func (m *Member) Client(scheme bool, eps ...string) (cli *clientv3.Client, tlsCfg *tls.Config, err error)
Client creates a client from a member. If 'eps' is not empty, it overwrites clientv3.Config.Endpoints. If 'embedded' is true, it ignores 'scheme' and 'eps' arguments, since it directly connects to a single embedded server.
func (*Member) FetchMemberStatus ¶
FetchMemberStatus fetches member status (make sure to close the client outside of this function).
Source Files
¶
- cluster.go
- cluster_other.go
- doc.go
- logger.go
- member.go
- utils.go