async fn delete_projection(
    client: &ProjectionClient,
    gen_name: &mut names::Generator<'_>,
) -> Result<(), Box<dyn std::error::Error>> {
    let name = gen_name.next().unwrap();
    client
        .create(
            name.as_str(),
            PROJECTION_FILE.to_string(),
            &Default::default(),
        )
        .await?;

    wait_until_projection_status_is(client, name.as_str(), "Running").await?;

    debug!("delete_projection: create_projection succeeded: {}", name);

    client.abort(name.as_str(), None).await?;

    wait_until_projection_status_is(client, name.as_str(), "Aborted").await?;

    debug!("delete_projection: reading newly-created projection statistic succeeded");

    let cloned_name = name.clone();
    // There is a race-condition in the projection manager: https://github.com/EventStore/EventStore/issues/2938
    let result = tokio::time::timeout(std::time::Duration::from_secs(10), async move {
        loop {
            let result = client
                .delete(cloned_name.as_str(), &Default::default())
                .await;

            if result.is_ok() {
                break;
            }

            warn!("projection deletion failed with: {:?}. Retrying...", result);
            let _ = tokio::time::sleep(std::time::Duration::from_millis(500)).await;
        }
    })
    .await;

    if result.is_err() {
        warn!("projection deletion didn't complete under test timeout. Not a big deal considering https://github.com/EventStore/EventStore/issues/2938");
    }

    Ok(())
}
// TODO - A projection must be stopped to be able to delete it. But Stop projection gRPC call doesn't exist yet.
A projection must be stopped to be able to delete it. But Stop projection gRPC call doesn't exist yet.
A projection must be stopped to be able to delete it . But Stop projection gRPC call doesn ' t exist yet .
async fn delete_projection(
    client: &ProjectionClient,
    gen_name: &mut names::Generator<'_>,
) -> Result<(), Box<dyn std::error::Error>> {
    let name = gen_name.next().unwrap();
    client
        .create(
            name.as_str(),
            PROJECTION_FILE.to_string(),
            &Default::default(),
        )
        .await?;
    wait_until_projection_status_is(client, name.as_str(), "Running").await?;
    debug!("delete_projection: create_projection succeeded: {}", name);
    client.abort(name.as_str(), None).await?;
    wait_until_projection_status_is(client, name.as_str(), "Aborted").await?;
    debug!("delete_projection: reading newly-created projection statistic succeeded");
    let cloned_name = name.clone();
    // There is a race-condition in the projection manager: https://github.com/EventStore/EventStore/issues/2938
    let result = tokio::time::timeout(std::time::Duration::from_secs(10), async move {
        loop {
            let result = client
                .delete(cloned_name.as_str(), &Default::default())
                .await;
            if result.is_ok() {
                break;
            }
            warn!("projection deletion failed with: {:?}. Retrying...", result);
            let _ = tokio::time::sleep(std::time::Duration::from_millis(500)).await;
        }
    })
    .await;
    if result.is_err() {
        warn!("projection deletion didn't complete under test timeout. Not a big deal considering https://github.com/EventStore/EventStore/issues/2938");
    }
    Ok(())
}
async fn delete_projection ( client : & ProjectionClient , gen_name : & mut names :: Generator < ' _ > , ) -> Result < ( ) , Box < dyn std :: error :: Error > > { let name = gen_name . next ( ) . unwrap ( ) ; client . create ( name . as_str ( ) , PROJECTION_FILE . to_string ( ) , & Default :: default ( ) , ) . await ? ; wait_until_projection_status_is ( client , name . as_str ( ) , " " ) . await ? ; debug ! ( " " name ) ; client . abort ( name . as_str ( ) , None ) . await ? ; wait_until_projection_status_is ( client , name . as_str ( ) , " " ) . await ? ; debug ! ( " " ) ; let cloned_name = name . clone ( ) ; // There is a race-condition in the projection manager: https://github.com/EventStore/EventStore/issues/2938 let result = tokio :: time :: timeout ( std :: time :: Duration :: from_secs ( 10 ) , async move { loop { let result = client . delete ( cloned_name . as_str ( ) , & Default :: default ( ) ) . await ; if result . is_ok ( ) { break ; } warn ! ( " " result ) ; let _ = tokio :: time :: sleep ( std :: time :: Duration :: from_millis ( 500 ) ) . await ; } } ) . await ; if result . is_err ( ) { warn ! ( " " ) ; } Ok ( ( ) ) }
TODO - A projection must be stopped to be able to delete it.
TODO - A projection must be stopped to be able to delete it .
client
&ProjectionClient
gen_name
&mut names::Generator<'_>
client
&ProjectionClient
gen_name
&mut names::Generator<'_>