MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / waitForProcessedTotal

Method waitForProcessedTotal

db/event_manager_test.go:363–381  ·  view source on GitHub ↗
(ctx context.Context, waitCount int, maxWaitTime time.Duration)

Source from the content-addressed store, hash-verified

361}
362
363func (em *EventManager) waitForProcessedTotal(ctx context.Context, waitCount int, maxWaitTime time.Duration) error {
364 startTime := time.Now()
365
366 worker := func() (bool, error, interface{}) {
367 eventTotal := em.GetEventsProcessedSuccess() + em.GetEventsProcessedFail()
368 if eventTotal >= int64(waitCount) {
369 base.DebugfCtx(ctx, base.KeyAll, "waitForProcessedTotal(%d) took %v", waitCount, time.Since(startTime))
370 return false, nil, nil
371 }
372
373 return true, nil, nil
374 }
375
376 ctx, cancel := context.WithDeadline(ctx, startTime.Add(maxWaitTime))
377 sleeper := base.SleeperFuncCtx(base.CreateMaxDoublingSleeperFunc(math.MaxInt64, 1, 1000), ctx)
378 err, _ := base.RetryLoop(ctx, fmt.Sprintf("waitForProcessedTotal(%d)", waitCount), worker, sleeper)
379 cancel()
380 return err
381}
382
383func GetRouterWithHandler(wr *WebhookRequest) http.Handler {
384 r := http.NewServeMux()

Callers 4

TestWebhookBasicFunction · 0.95
TestWebhookOverflowsFunction · 0.95
TestWebhookOldDocFunction · 0.95
TestWebhookTimeoutFunction · 0.95

Calls 8

DebugfCtxFunction · 0.92
SleeperFuncCtxFunction · 0.92
RetryLoopFunction · 0.92
SinceMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected