swarm: bash task status keys expire after 72 hours
Nothing deletes the key of a finished task, so the bucket would grow with every task an agent runs. The shared bucket helper takes an optional max age, applied when the bucket is created; a live task's republishing keeps its own key.
This commit is contained in:
parent
1779fa0568
commit
1a698f1a97
1 changed files with 35 additions and 3 deletions
|
|
@ -32,16 +32,19 @@ pub(crate) fn output_config(
|
|||
}
|
||||
|
||||
/// Open the status bucket, creating it if nothing has yet. `history: 1`: a
|
||||
/// reader wants each task's current state, not every state it has been in.
|
||||
/// reader wants each task's current state, not every state it has been in. A
|
||||
/// key expires [`swarm_wire::bash_task::STATUS_MAX_AGE`] after its last write,
|
||||
/// since nothing deletes the key of a finished task.
|
||||
pub async fn open_status(
|
||||
client: &async_nats::Client,
|
||||
) -> Result<async_nats::jetstream::kv::Store, crate::Error> {
|
||||
let js = async_nats::jetstream::new(client.clone());
|
||||
crate::kv::open_or_create(
|
||||
crate::kv::open_or_create_expiring(
|
||||
&js,
|
||||
swarm_wire::bash_task::BUCKET,
|
||||
"bash-task-status",
|
||||
"The state of each bash task, as its agent's bash MCP last published it".to_owned(),
|
||||
Some(swarm_wire::bash_task::STATUS_MAX_AGE),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue