mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-09 10:56:20 +00:00
WIP
This commit is contained in:
parent
930be6706f
commit
363e3cae4b
2 changed files with 23 additions and 3 deletions
|
@ -231,9 +231,23 @@ impl Database {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_stale_servers(&self, environment: &str, new_epoch: ServerEpoch) -> Result<()> {
|
pub async fn delete_stale_servers(
|
||||||
self.transaction(|tx| async {
|
&self,
|
||||||
server::Entity::delete_many().filter(Condition::all().add())
|
new_epoch: ServerEpoch,
|
||||||
|
environment: &str,
|
||||||
|
) -> Result<()> {
|
||||||
|
self.transaction(|tx| async move {
|
||||||
|
server::Entity::delete_many()
|
||||||
|
.filter(
|
||||||
|
Condition::all().add(
|
||||||
|
server::Column::Environment
|
||||||
|
.eq(environment)
|
||||||
|
.add(server::Column::Epoch.ne(new_epoch)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.exec(&*tx)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,6 +351,12 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app_state
|
||||||
|
.db
|
||||||
|
.delete_stale_servers(epoch, &app_state.config.zed_environment)
|
||||||
|
.await
|
||||||
|
.trace_err();
|
||||||
}
|
}
|
||||||
.instrument(span),
|
.instrument(span),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue