Skip to main content

replicate_object

Function replicate_object 

Source
pub async fn replicate_object<F, Fut>(
    rule: ReplicationRule,
    source_bucket: String,
    source_key: String,
    body: Bytes,
    metadata: Option<HashMap<String, String>>,
    do_put: F,
    manager: Arc<ReplicationManager>,
)
where F: Fn(String, String, Bytes, Option<HashMap<String, String>>) -> Fut, Fut: Future<Output = Result<(), String>>,
Expand description

Replicate one source-bucket object to the rule’s destination bucket.

The caller supplies a do_put callback that performs the actual destination-bucket PUT (so unit tests can drive the dispatcher without needing a full backend). The callback receives: (destination_bucket, key, body, metadata) and returns a Result<(), String> whose Err triggers the retry / failure path.

Behaviour:

  • Stamps the destination metadata with x-amz-replication-status: REPLICA so a HEAD on the replica is distinguishable.
  • On callback success, records (source_bucket, source_key) → Completed in the manager.
  • On callback failure, retries up to [RETRY_ATTEMPTS] times with exponential backoff (50ms / 100ms / 200ms). After the budget is exhausted, records Failed, bumps dropped_total, and emits the matching Prometheus counter.