mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-08 18:41:48 +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
|
||||
}
|
||||
|
||||
fn delete_stale_servers(&self, environment: &str, new_epoch: ServerEpoch) -> Result<()> {
|
||||
self.transaction(|tx| async {
|
||||
server::Entity::delete_many().filter(Condition::all().add())
|
||||
pub async fn delete_stale_servers(
|
||||
&self,
|
||||
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
|
||||
}
|
||||
|
|
|
@ -351,6 +351,12 @@ impl Server {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
app_state
|
||||
.db
|
||||
.delete_stale_servers(epoch, &app_state.config.zed_environment)
|
||||
.await
|
||||
.trace_err();
|
||||
}
|
||||
.instrument(span),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue