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

Method Start

db/active_replicator_common.go:144–173  ·  view source on GitHub ↗

Start starts the replicator, setting the state to ReplicationStateStarting and starting the status reporter.

(ctx context.Context)

Source from the content-addressed store, hash-verified

142
143// Start starts the replicator, setting the state to ReplicationStateStarting and starting the status reporter.
144func (arc *activeReplicatorCommon) Start(ctx context.Context) error {
145 arc.lock.Lock()
146 defer arc.lock.Unlock()
147
148 if arc.ctx != nil && arc.ctx.Err() == nil {
149 return fmt.Errorf("Replicator is already running")
150 }
151
152 arc.setState(ReplicationStateStarting)
153 logCtx := base.CorrelationIDLogCtx(ctx,
154 arc.config.ID+"-"+string(arc.direction))
155 arc.ctx, arc.ctxCancel = context.WithCancel(logCtx)
156
157 arc.startStatusReporter(arc.ctx)
158
159 err := arc.replicatorConnectFn()
160 if err != nil {
161 arc.setError(err)
162 base.WarnfCtx(arc.ctx, "Couldn't connect: %s", err)
163 if errors.Is(err, fatalReplicatorConnectError) {
164 base.WarnfCtx(arc.ctx, "Stopping replication connection attempt")
165 defer arc.ctxCancel()
166 } else {
167 base.InfofCtx(arc.ctx, base.KeyReplicate, "Attempting to reconnect in background: %v", err)
168 arc.reconnect()
169 }
170 }
171 arc._publishStatus()
172 return err
173}
174
175// initCheckpointer starts a checkpointer. The remoteCheckpoints are only for collections and indexed by the blip collectionIdx. If using default collection only, replicationCheckpoints is an empty array.
176func (arc *activeReplicatorCommon) _initCheckpointer(remoteCheckpoints []replicationCheckpoint) error {

Callers

nothing calls this directly

Calls 12

setStateMethod · 0.95
startStatusReporterMethod · 0.95
setErrorMethod · 0.95
reconnectMethod · 0.95
_publishStatusMethod · 0.95
CorrelationIDLogCtxFunction · 0.92
WarnfCtxFunction · 0.92
InfofCtxFunction · 0.92
ErrMethod · 0.80
ErrorfMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected