forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/config"
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/media"
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/objectstore"
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/pipeline"
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/store/postgres"
|
||||
)
|
||||
|
||||
// reconcile runs a bounded dry-run scan unless the operator explicitly supplies apply.
|
||||
func reconcile(apply bool) error {
|
||||
cfg, err := config.NewPersistence()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s3, err := config.NewObjectStore()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
database, err := postgres.New(postgres.Options{URL: cfg.DatabaseURL, MaxConnections: 1, Timeout: 5 * time.Second})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer database.Close()
|
||||
objects, err := objectstore.New(s3)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancel()
|
||||
if apply {
|
||||
if _, err := pipeline.Cleanup(ctx, database, objects); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return media.RunReconciliation(ctx, database, objects, os.Stdout, apply)
|
||||
}
|
||||
Reference in New Issue
Block a user