forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package pipeline
|
||||
|
||||
import "context"
|
||||
|
||||
// Retention owns replay fencing and deletion acknowledgements.
|
||||
type Retention interface {
|
||||
// ExpireStaging claims at most 100 old terminal source keys.
|
||||
ExpireStaging(context.Context) ([]string, error)
|
||||
// StagingRemoved acknowledges idempotent source removal.
|
||||
StagingRemoved(context.Context, string) error
|
||||
}
|
||||
|
||||
// Remover deletes only a server-claimed immutable key.
|
||||
type Remover interface {
|
||||
// Remove is safe to repeat after an uncertain acknowledgement.
|
||||
Remove(context.Context, string) error
|
||||
}
|
||||
|
||||
// Cleanup removes expired staging only after the database has excluded replay.
|
||||
func Cleanup(ctx context.Context, store Retention, objects Remover) (int, error) {
|
||||
keys, err := store.ExpireStaging(ctx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
removed := 0
|
||||
for _, key := range keys {
|
||||
if err := objects.Remove(ctx, key); err != nil {
|
||||
return removed, err
|
||||
}
|
||||
if err := store.StagingRemoved(ctx, key); err != nil {
|
||||
return removed, err
|
||||
}
|
||||
removed++
|
||||
}
|
||||
return removed, nil
|
||||
}
|
||||
Reference in New Issue
Block a user