Files
query-orchestration/cmd/docTextRunner/main.go
T

65 lines
1.3 KiB
Go
Raw Normal View History

// **Listens For**: Body Containing Document ID
//
// **Action**.
//
// If the document text is not already extracted according to the collector standards, trigger the textract job for text detection.
//
// Otherwise, add an event to the QUERYSYNC queue.
package main
import (
"context"
"log/slog"
"os"
2025-03-05 12:05:46 +00:00
doctextrunner "queryorchestration/api/docTextRunner"
documenttext "queryorchestration/internal/document/text"
"queryorchestration/internal/server/runner"
"queryorchestration/internal/serviceconfig/objectstore"
"queryorchestration/internal/serviceconfig/queue/querysync"
"queryorchestration/internal/serviceconfig/textract"
_ "github.com/lib/pq"
)
type DocTextConfig struct {
runner.BaseConfig[doctextrunner.Body]
textract.TextractConfig
querysync.QuerySyncConfig
objectstore.ObjectStoreConfig
}
func main() {
ctx := context.Background()
cfg := &DocTextConfig{}
cfg.ControllerFunc = func() runner.Controller[doctextrunner.Body] {
text := documenttext.New(cfg)
return doctextrunner.New(&doctextrunner.Services{
Text: text,
})
}
server, err := runner.New(ctx, cfg)
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}
err = cfg.SetStoreClient(ctx)
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}
err = cfg.SetTextractClient(ctx)
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}
server.Listen(ctx)
}