a6e081e5cd
inject and print version at startup for all services * inject and print version * coverage
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
// **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"
|
|
|
|
doctextrunner "queryorchestration/api/docTextRunner"
|
|
documenttext "queryorchestration/internal/document/text"
|
|
"queryorchestration/internal/server/runner"
|
|
"queryorchestration/internal/serviceconfig/build"
|
|
"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() {
|
|
// Print version information before any environment checks
|
|
build.PrintVersionInfo("docTextRunner")
|
|
|
|
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)
|
|
}
|