Repository: qdrant/qdrant
File: src/actix/api/update_api.rs (Rust)

Code before:
}

/// Request body for the staging test delay endpoint.
/// Only available when the `staging` feature is enabled.
#[cfg(feature = "staging")]
#[derive(Debug, Deserialize, Validate)]
pub struct TestDelayRequest {
    /// Duration of the delay in seconds (default: 1.0, max: 300.0).
    #[serde(default = "default_test_delay_duration")]
    #[validate(range(min = 0.0, max = 300.0))]
    pub duration: f64,
}

#[cfg(feature = "staging")]
fn default_test_delay_duration() -> f64 {
    1.0
}

/// Staging endpoint that introduces an artificial delay for testing purposes.
/// Only available when the `staging` feature is enabled.
#[cfg(feature = "staging")]
#[post("/collections/{name}/points/staging")]
async fn staging_test_delay(
    dispatcher: web::Data<Dispatcher>,
    collection: Path<CollectionPath>,
    operation: Json<TestDelayRequest>,
    ActixAccess(access): ActixAccess,
) -> impl Responder {
    use collection::operations::point_ops::PointOperations;
    use collection::operations::verification::new_unchecked_verification_pass;
    use ordered_float::OrderedFloat;
    use shard::operations::CollectionUpdateOperations;
    use shard::operations::point_ops::TestDelayUpsertPointsOperation;

    let timing = Instant::now();
    let operation = operation.into_inner();
    let collection_name = collection.into_inner().name;

    let point_operation = PointOperations::TestDelayUpsertPoints(TestDelayUpsertPointsOperation {
        duration: OrderedFloat(operation.duration),
    });

    let collection_operation = CollectionUpdateOperations::PointOperation(point_operation);

    // Get TOC with unchecked verification pass (staging operations don't need strict mode)
    let pass = new_unchecked_verification_pass();
    let toc = dispatcher.toc(&access, &pass);

    let result = crate::common::update::update(
        toc,
        &collection_name,

Review comment (suggestion):
I'd be better to accept a PointOperation type here. Or a dedicated type for staging stuff once we've added a variant in `CollectionUpdateOperations`.

It'll be a bit more verbose in usage, but it also means all new operations we add are immediately usable without implementing a new API.

Code after:
}

/// Request body for the staging test delay endpoint.
/// Only available when the `staging` feature is enabled.
#[cfg(feature = "staging")]
#[derive(Debug, Deserialize, Validate)]
pub struct TestDelayRequest {
    /// Duration of the delay in seconds (default: 1.0, max: 300.0).
    #[serde(default = "default_test_delay_duration")]
    #[validate(range(min = 0.0, max = 300.0))]
    pub duration: f64,
}

#[cfg(feature = "staging")]
fn default_test_delay_duration() -> f64 {
    1.0
}

/// Staging endpoint that introduces an artificial delay for testing purposes.
/// Only available when the `staging` feature is enabled.
#[cfg(feature = "staging")]
#[post("/collections/{name}/points/staging")]
async fn staging_test_delay(
    dispatcher: web::Data<Dispatcher>,
    collection: Path<CollectionPath>,
    operation: Json<TestDelayRequest>,
    params: Query<UpdateParams>,
    ActixAccess(access): ActixAccess,
) -> impl Responder {
    use collection::operations::point_ops::PointOperations;
    use collection::operations::verification::new_unchecked_verification_pass;
    use shard::operations::CollectionUpdateOperations;
    use shard::operations::staging::TestDelayOperation;

    let timing = Instant::now();
    let operation = operation.into_inner();
    let collection_name = collection.into_inner().name;

    let point_operation = PointOperations::TestDelay(TestDelayOperation::new(operation.duration));

    let collection_operation = CollectionUpdateOperations::PointOperation(point_operation);

    // Get TOC with unchecked verification pass (staging operations don't need strict mode)
    let pass = new_unchecked_verification_pass();
    let toc = dispatcher.toc(&access, &pass);

    let result = crate::common::update::update(
        toc,
        &collection_name,
        collection_operation,
        InternalUpdateParams::default(),