chore(server): rename daemon to startRoutine

For better understanding.
This commit is contained in:
Yicheng Qin 2014-05-07 07:51:44 -07:00
parent e55512f60b
commit 6516cf854c
2 changed files with 11 additions and 11 deletions

View File

@ -33,7 +33,7 @@ func init() {
defaultDiscoverer = &Discoverer{}
}
func (d *Discoverer) Do(discoveryURL string, name string, peer string, closeChan <-chan bool, daemon func(func())) (peers []string, err error) {
func (d *Discoverer) Do(discoveryURL string, name string, peer string, closeChan <-chan bool, startRoutine func(func())) (peers []string, err error) {
d.name = name
d.peer = peer
d.discoveryURL = discoveryURL
@ -68,7 +68,7 @@ func (d *Discoverer) Do(discoveryURL string, name string, peer string, closeChan
// Start the very slow heartbeat to the cluster now in anticipation
// that everything is going to go alright now
daemon(func() { d.startHeartbeat(closeChan) })
startRoutine(func() { d.startHeartbeat(closeChan) })
// Attempt to take the leadership role, if there is no error we are it!
resp, err := d.client.Create(path.Join(d.prefix, stateKey), startedState, 0)
@ -143,6 +143,6 @@ func (d *Discoverer) heartbeat() error {
return err
}
func Do(discoveryURL string, name string, peer string, closeChan <-chan bool, daemon func(func())) ([]string, error) {
return defaultDiscoverer.Do(discoveryURL, name, peer, closeChan, daemon)
func Do(discoveryURL string, name string, peer string, closeChan <-chan bool, startRoutine func(func())) ([]string, error) {
return defaultDiscoverer.Do(discoveryURL, name, peer, closeChan, startRoutine)
}

View File

@ -287,14 +287,14 @@ func (s *PeerServer) Start(snapshot bool, discoverURL string, peers []string) er
s.closeChan = make(chan bool)
s.daemon(s.monitorSync)
s.daemon(s.monitorTimeoutThreshold)
s.daemon(s.monitorActiveSize)
s.daemon(s.monitorPeerActivity)
s.startRoutine(s.monitorSync)
s.startRoutine(s.monitorTimeoutThreshold)
s.startRoutine(s.monitorActiveSize)
s.startRoutine(s.monitorPeerActivity)
// open the snapshot
if snapshot {
s.daemon(s.monitorSnapshot)
s.startRoutine(s.monitorSnapshot)
}
return nil
@ -430,7 +430,7 @@ func (s *PeerServer) Upgradable() error {
// Helper function to do discovery and return results in expected format
func (s *PeerServer) handleDiscovery(discoverURL string) (peers []string, err error) {
peers, err = discovery.Do(discoverURL, s.Config.Name, s.Config.URL, s.closeChan, s.daemon)
peers, err = discovery.Do(discoverURL, s.Config.Name, s.Config.URL, s.closeChan, s.startRoutine)
// Warn about errors coming from discovery, this isn't fatal
// since the user might have provided a peer list elsewhere,
@ -672,7 +672,7 @@ func (s *PeerServer) logSnapshot(err error, currentIndex, count uint64) {
}
}
func (s *PeerServer) daemon(f func()) {
func (s *PeerServer) startRoutine(f func()) {
s.routineGroup.Add(1)
go func() {
defer s.routineGroup.Done()