feat(qa): add synthesis conversations with source retention (#52)
This commit is contained in:
25
backend/internal/summaryqa/purge.go
Normal file
25
backend/internal/summaryqa/purge.go
Normal file
@ -0,0 +1,25 @@
|
||||
package summaryqa
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Cleanup is retryable and deletes only expired temporary source rows. API reads
|
||||
// also enforce expiration independently; a delayed worker never grants access.
|
||||
func RunPurger(ctx context.Context, repo Repository, interval time.Duration, onFailure func()) {
|
||||
ticker := time.NewTicker(interval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
attempt, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
if err := repo.PurgeExpiredQASources(attempt, time.Now()); err != nil && ctx.Err() == nil && onFailure != nil {
|
||||
onFailure()
|
||||
}
|
||||
cancel()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user