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

Method UpdateReplicationState

db/sg_replicate_cfg.go:1157–1181  ·  view source on GitHub ↗
(replicationID string, state string)

Source from the content-addressed store, hash-verified

1155}
1156
1157func (m *sgReplicateManager) UpdateReplicationState(replicationID string, state string) error {
1158
1159 updateReplicationStatusCallback := func(cluster *SGRCluster) (cancel bool, err error) {
1160 replicationCfg, exists := cluster.Replications[replicationID]
1161 if !exists {
1162 return true, base.ErrNotFound
1163 }
1164
1165 stateChangeErr := isValidStateChange(replicationCfg.TargetState, state)
1166 if stateChangeErr != nil {
1167 return true, stateChangeErr
1168 }
1169
1170 if state == ReplicationStateStopped && replicationCfg.Adhoc == true {
1171 delete(cluster.Replications, replicationID)
1172 cluster.RebalanceReplications()
1173 return false, nil
1174 }
1175
1176 cluster.Replications[replicationID].TargetState = state
1177 cluster.RebalanceReplications()
1178 return false, nil
1179 }
1180 return m.updateCluster(updateReplicationStatusCallback)
1181}
1182
1183func isValidStateChange(currentState, newState string) error {
1184

Callers 3

replicationCompleteMethod · 0.95
RefreshReplicationCfgMethod · 0.95
PutReplicationStatusMethod · 0.95

Calls 3

updateClusterMethod · 0.95
isValidStateChangeFunction · 0.85
RebalanceReplicationsMethod · 0.80

Tested by

no test coverage detected