| 164 | } |
| 165 | |
| 166 | func (w *InMemoryAutoRefresh) Start(ctx context.Context) error { |
| 167 | for i := uint(0); i < w.parallelizm; i++ { |
| 168 | go func(ctx context.Context) { |
| 169 | err := w.sync(ctx) |
| 170 | if err != nil { |
| 171 | logger.Errorf(ctx, "Failed to sync. Error: %v", err) |
| 172 | } |
| 173 | }(contextutils.WithGoroutineLabel(ctx, fmt.Sprintf("%v-worker-%v", w.name, i))) |
| 174 | } |
| 175 | |
| 176 | enqueueCtx := contextutils.WithGoroutineLabel(ctx, fmt.Sprintf("%v-enqueue", w.name)) |
| 177 | go w.enqueueLoop(enqueueCtx) |
| 178 | |
| 179 | return nil |
| 180 | } |
| 181 | |
| 182 | func (w *InMemoryAutoRefresh) enqueueLoop(ctx context.Context) { |
| 183 | timer := w.clock.NewTimer(w.syncPeriod) |