setLocalStatus updates replication status.
(ctx context.Context, metadataStore base.DataStore, statusKey string, status *ReplicationStatus, localDocExpirySecs int)
| 547 | |
| 548 | // setLocalStatus updates replication status. |
| 549 | func setLocalStatus(ctx context.Context, metadataStore base.DataStore, statusKey string, status *ReplicationStatus, localDocExpirySecs int) (err error) { |
| 550 | base.TracefCtx(ctx, base.KeyReplicate, "setLocalStatus for %q (%#+v)", statusKey, status) |
| 551 | |
| 552 | // obtain current rev |
| 553 | currentStatus, err := getLocalStatusDoc(ctx, metadataStore, statusKey) |
| 554 | if err != nil { |
| 555 | base.WarnfCtx(ctx, "Unable to retrieve local status doc for %s, status not updated", statusKey) |
| 556 | return nil |
| 557 | } |
| 558 | |
| 559 | var revID string |
| 560 | if currentStatus != nil { |
| 561 | revID = currentStatus.Rev |
| 562 | } |
| 563 | |
| 564 | newStatus := &ReplicationStatusDoc{ |
| 565 | Status: status, |
| 566 | } |
| 567 | |
| 568 | _, _, err = putDocWithRevision(metadataStore, statusKey, revID, newStatus.AsBody(), localDocExpirySecs) |
| 569 | return err |
| 570 | } |
| 571 | |
| 572 | // removeLocalStatus removes a replication status from the given metadataStore. This is done when a replication is reset. |
| 573 | func removeLocalStatus(ctx context.Context, metadataStore base.DataStore, statusKey string) (err error) { |
no test coverage detected