fix(pier): reap stateful sessions whose store record expired
- a reaper started at Mount checks every local session against the store every min(idle_ttl/2, 1m) and closes each copy whose record is gone, logging the expired step (A-CR-01, A-IN-06) - the GET stream re-check ends the stream when the record is gone (A-IN-01) - tool calls served without a session on the stateful path log the session as ephemeral (A-IN-06) - TestPierReaperSmoke and the ReapNow, LocalSessions, StopReaper seams
This commit is contained in:
@@ -57,6 +57,12 @@ type Pier struct {
|
||||
appName string
|
||||
version string
|
||||
instance string
|
||||
|
||||
// stopReap ends the session reaper Mount starts. backpack.App has no
|
||||
// shutdown hook yet, so in production the reaper runs for the life of
|
||||
// the process, like the store subscription; when backpack gains one,
|
||||
// Mount registers stopReap there.
|
||||
stopReap context.CancelFunc
|
||||
}
|
||||
|
||||
// Mount reads the mcp.* keys and, when mcp.enabled is true, compiles every
|
||||
@@ -130,6 +136,9 @@ func Mount(host Host, app *backpack.App, plugins []party.Plugin) error {
|
||||
if err := app.Publish(p); err != nil {
|
||||
return fmt.Errorf("pier: publishing the endpoint: %w", err)
|
||||
}
|
||||
reapCtx, stop := context.WithCancel(context.Background())
|
||||
p.stopReap = stop
|
||||
go p.sessions.reap(reapCtx, reapInterval(cfg.IdleTTL))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user