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

Method Complete

db/active_replicator_pull.go:127–158  ·  view source on GitHub ↗

Complete gracefully shuts down a replication, waiting for all in-flight revisions to be processed before stopping the replication

()

Source from the content-addressed store, hash-verified

125// Complete gracefully shuts down a replication, waiting for all in-flight revisions to be processed
126// before stopping the replication
127func (apr *ActivePullReplicator) Complete() {
128 base.TracefCtx(apr.ctx, base.KeyReplicate, "ActivePullReplicator.Complete()")
129 apr.lock.Lock()
130 _ = apr.forEachCollection(func(c *activeReplicatorCollection) error {
131 base.TracefCtx(apr.ctx, base.KeyReplicate, "Before calling waitForExpectedSequences in Complete()")
132 if err := c.Checkpointer.waitForExpectedSequences(); err != nil {
133 base.InfofCtx(apr.ctx, base.KeyReplicate, "Couldn't drain replication %s - stopping anyway: %v", apr.config.ID, err)
134 }
135 base.TracefCtx(apr.ctx, base.KeyReplicate, "After calling waitForExpectedSequences in Complete()")
136 return nil
137 })
138
139 apr._stop()
140
141 base.TracefCtx(apr.ctx, base.KeyReplicate, "Calling disconnect from Complete() in active replicator pull")
142 stopErr := apr._disconnect()
143 if stopErr != nil {
144 base.InfofCtx(apr.ctx, base.KeyReplicate, "Error attempting to stop replication %s: %v", apr.config.ID, stopErr)
145 }
146 apr.setState(ReplicationStateStopped)
147
148 // unlock the replication before triggering callback, in case callback attempts to access replication information
149 // from the replicator
150 onCompleteCallback := apr.onReplicatorComplete
151
152 apr._publishStatus()
153 apr.lock.Unlock()
154
155 if onCompleteCallback != nil {
156 onCompleteCallback()
157 }
158}
159
160// _getStatus returns current replicator status. Requires holding ActivePullReplicator.lock as a read lock.
161func (apr *ActivePullReplicator) _getStatus() *ReplicationStatus {

Callers 1

Calls 10

TracefCtxFunction · 0.92
InfofCtxFunction · 0.92
forEachCollectionMethod · 0.80
_stopMethod · 0.80
_disconnectMethod · 0.80
setStateMethod · 0.80
_publishStatusMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected