func (a *App) refreshLog(ctx context.Context, name string) { info, e := a.client.GetLog(name) for { topsl.AppLock() if a.logName == name { a.logInfo = info a.logErr = e topsl.AppUnlock() topsl.AppDraw() } else { topsl.AppUnlock() return } select { case <-ctx.Done(): return default: } info, e = a.client.WatchLog(ctx, name, info) } }
func (a *App) refresh() { client := a.client etag := "" for { items, e := a.getItems() topsl.AppLock() a.items = items a.err = e topsl.AppUnlock() topsl.AppDraw() ctx, cancel := context.WithTimeout(context.Background(), time.Hour) etag, e = client.Watch(ctx, etag) cancel() if e != nil { time.Sleep(2 * time.Second) } } }