Rename 'reclaim' to 'noErrorUnknown' which describes the behaviour better

This commit is contained in:
Bryan Boreham committed 2015-07-23 20:16:30 +01:00
1 parent 647b755b64
commit f0915221d1
4 files changed
+13 -14

No files matched your search

+8 -9
View File
@@ -9,12 +9,13 @@ import (
)
type claim struct {
resultChan chan<- error
ident string
addr address.Address
reclaim bool
resultChan chan<- error
ident string
addr address.Address
noErrorOnUnknown bool
}
// Send an error (or nil for success) back to caller listening on resultChan
func (c *claim) sendResult(result error) {
// Make sure we only send a result once, since listener stops listening after that
if c.resultChan != nil {
@@ -32,9 +33,7 @@ func (c *claim) sendResult(result error) {
func (c *claim) Try(alloc *Allocator) bool {
if !alloc.ring.Contains(c.addr) {
// Address not within our universe; assume user knows what they are doing
if c.reclaim {
alloc.infof("Ignored address %s claimed by %s - not in our universe", c.addr, c.ident)
}
alloc.infof("Ignored address %s claimed by %s - not in our universe", c.addr, c.ident)
c.sendResult(nil)
return true
}
@@ -44,7 +43,7 @@ func (c *claim) Try(alloc *Allocator) bool {
// success
case router.UnknownPeerName:
// If our ring doesn't know, it must be empty.
if c.reclaim {
if c.noErrorOnUnknown {
alloc.infof("Claim %s for %s: address allocator still initializing; will try later.", c.addr, c.ident)
c.sendResult(nil) // don't make the caller wait
} else {
@@ -55,7 +54,7 @@ func (c *claim) Try(alloc *Allocator) bool {
alloc.debugf("requesting address %s from other peer %s", c.addr, owner)
err := alloc.sendSpaceRequest(owner, address.NewRange(c.addr, 1))
if err != nil { // can't speak to owner right now
if c.reclaim { // don't hold up launch; figure it out later
if c.noErrorOnUnknown {
alloc.infof("Claim %s for %s: %s; will try later.", c.addr, c.ident, err)
c.sendResult(nil)
} else { // just tell the user they can't do this.