feat: process attachments through durable versioned jobs

This commit is contained in:
Vladislav Agapov
2026-10-29 16:56:06 +03:00
parent 276dbdad8a
commit e35c8f0b75
235 changed files with 17028 additions and 44 deletions
+55
View File
@@ -0,0 +1,55 @@
package media
import (
"context"
"encoding/json"
"io"
"time"
"github.com/google/uuid"
)
// ReconcileMetadata combines bounded database inventory operations for the operator workflow.
type ReconcileMetadata interface {
Inventory
OrphanMetadata
}
// ReconcileObjects combines object inspection and listing for the operator workflow.
type ReconcileObjects interface {
ObjectInventory
OrphanObjects
}
// RunReconciliation emits one bounded result per page and stops on any uncertain dependency outcome.
func RunReconciliation(ctx context.Context, metadata ReconcileMetadata, objects ReconcileObjects, output io.Writer, apply bool) error {
encoder := json.NewEncoder(output)
after := uuid.Nil
for {
result, err := Reconcile(ctx, metadata, objects, after, time.Hour, apply)
if err != nil {
return err
}
if err := encoder.Encode(result); err != nil {
return err
}
if result.Scanned < 1000 {
break
}
after = result.Next
}
key := ""
for {
result, err := ReconcileOrphans(ctx, metadata, objects, key, time.Hour, apply)
if err != nil {
return err
}
if err := encoder.Encode(result); err != nil {
return err
}
if result.Scanned < 1000 {
return nil
}
key = result.Next
}
}