// **Listens For**: S3 Event notifications - limited to PUT notifications. // // **Action**. // // Checks if the uploaded document is a duplicate. // // Currently whether the document content is a duplicate or not is determines using the document ETag, and check if it already exists for the client. // // Find reference entity. // // If NOT a duplicate - Create a document reference entity. // // Create a document entry to log the successful upload of a document. // // Add an event to the DOC SYNC queue. package main import ( "context" "log/slog" "os" docinitrunner "queryorchestration/api/docInitRunner" documentinit "queryorchestration/internal/document/init" "queryorchestration/internal/server/runner" documentsyncc "queryorchestration/internal/serviceconfig/queue/documentsync" _ "github.com/lib/pq" ) type DocInitConfig struct { runner.BaseConfig[docinitrunner.Body] documentsyncc.DocSyncConfig } func main() { ctx := context.Background() cfg := &DocInitConfig{} cfg.ControllerFunc = func() runner.Controller[docinitrunner.Body] { docinit := documentinit.New(cfg) return docinitrunner.New(&docinitrunner.Services{ Document: docinit, Queries: cfg.GetDBQueries(), }) } server, err := runner.New(ctx, cfg) if err != nil { slog.Error(err.Error()) os.Exit(1) } // optional add shutdown metrics defer func() { err = cfg.GetMetrics().RecordLifecycleEvent(1.0, "shutdown", "main") if err != nil { slog.Error("Failed to record shutdown metric ", "error", err) } }() // start and block until server is done server.Listen(ctx) // optional shutdown metrics := cfg.GetMetrics() if err := metrics.Shutdown(ctx); err != nil { slog.Error("Error shutting down metrics server", "error", err) } }