Create MinionController to sync minions from cloudprovider (pkg cloudprovider/controller).

This commit is contained in:
Deyuan Deng
2014-10-08 19:14:37 -04:00
parent f603785698
commit ec46e94dc2
10 changed files with 350 additions and 475 deletions

View File

@@ -60,6 +60,19 @@ func Forever(f func(), period time.Duration) {
}
}
// OnceAndForever runs f first then loops forever running f every d. Catches any panics, and keeps going.
func OnceAndForever(f func(), period time.Duration) {
defer HandleCrash()
f()
for {
func() {
defer HandleCrash()
f()
}()
time.Sleep(period)
}
}
// EncodeJSON returns obj marshalled as a JSON string, ignoring any errors.
func EncodeJSON(obj interface{}) string {
data, _ := json.Marshal(obj)