Last active
September 21, 2015 13:20
-
-
Save calebamiles/d5229b5a86caf327ad6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type selectionFunc func(config.CPI) (string, error) | |
type reservationFunc func(config.CPI, string) (string, error) | |
func tryReservation(c config.CPI, choose selectionFunc, reserve reservationFunc) (string, error) { | |
var cid string | |
Loop: | |
for i := 0; i < maxRetries; i++ { | |
nodeID, loopErr := choose(c) | |
if loopErr != nil { | |
//log loopErr | |
continue | |
} | |
cid, loopErr = reserve(nodeID) | |
if loopErr != nil { | |
//log loopErr | |
continue | |
} | |
if cid != "" { | |
break Loop | |
} | |
} | |
if cid == "" { | |
return "", errors.New("unable to reserve node") | |
} | |
return cid, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment