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

Method Close

db/database.go:640–667  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

638}
639
640func (context *DatabaseContext) Close(ctx context.Context) {
641 context.BucketLock.Lock()
642 defer context.BucketLock.Unlock()
643
644 context.OIDCProviders.Stop()
645 close(context.terminator)
646 if context.cancelContextFunc != nil {
647 context.cancelContextFunc()
648 }
649
650 // Stop All background processors
651 bgManagers := context.stopBackgroundManagers()
652
653 // Wait for database background tasks to finish.
654 waitForBGTCompletion(ctx, BGTCompletionMaxWait, context.backgroundTasks, context.Name)
655 context.sequences.Stop(ctx)
656 context._stopOnlineProcesses(ctx)
657 // Stop the channel cache and its background tasks.
658 context.channelCache.Stop(ctx)
659
660 waitForBackgroundManagersToStop(ctx, BGTCompletionMaxWait, bgManagers)
661
662 context.Bucket.Close(ctx)
663 context.Bucket = nil
664
665 base.RemovePerDbStats(context.Name)
666
667}
668
669// stopBackgroundManagers stops any running BackgroundManager.
670// Returns a list of BackgroundManager it signalled to stop

Calls 9

_stopOnlineProcessesMethod · 0.95
RemovePerDbStatsFunction · 0.92
waitForBGTCompletionFunction · 0.85
StopMethod · 0.65
CloseMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45