Skip to content

Commit

Permalink
ringpop: add method to selfEvict from ring (#3132)
Browse files Browse the repository at this point in the history
  • Loading branch information
venkat1109 committed Mar 27, 2020
1 parent 29de9ee commit e816aa2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/membership/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ type (
common.Daemon

WhoAmI() (*HostInfo, error)
// EvictSelf evicts this member from the membership ring. After this method is
// called, other members will discover that this node is no longer part of the
// ring. This primitive is useful to carry out graceful host shutdown during deployments.
EvictSelf() error
Lookup(service string, key string) (*HostInfo, error)
GetResolver(service string) (ServiceResolver, error)
// AddListener adds a listener for this service.
Expand Down
14 changes: 14 additions & 0 deletions common/membership/interfaces_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions common/membership/rpMonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ func (rpo *ringpopMonitor) WhoAmI() (*HostInfo, error) {
return NewHostInfo(address, labels.AsMap()), nil
}

func (rpo *ringpopMonitor) EvictSelf() error {
return rpo.rp.SelfEvict()
}

func (rpo *ringpopMonitor) GetResolver(service string) (ServiceResolver, error) {
ring, found := rpo.rings[service]
if !found {
Expand Down
4 changes: 4 additions & 0 deletions host/simpleMonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func (s *simpleMonitor) Start() {
func (s *simpleMonitor) Stop() {
}

func (s *simpleMonitor) EvictSelf() error {
return nil
}

func (s *simpleMonitor) WhoAmI() (*membership.HostInfo, error) {
return s.hostInfo, nil
}
Expand Down

0 comments on commit e816aa2

Please sign in to comment.