2025-03-06 19:26:01 +00:00
|
|
|
// **Listens For**: Body Containing Document ID
|
|
|
|
|
//
|
|
|
|
|
// **Action**.
|
|
|
|
|
//
|
2025-04-02 18:50:03 +00:00
|
|
|
// If the document text is not already extracted according to the collector standards, trigger the textract job for text detection.
|
2025-03-06 19:26:01 +00:00
|
|
|
//
|
2025-04-02 18:50:03 +00:00
|
|
|
// Otherwise, add an event to the QUERYSYNC queue.
|
2025-02-07 14:15:06 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"log/slog"
|
|
|
|
|
"os"
|
2025-03-05 12:05:46 +00:00
|
|
|
|
2025-02-07 14:15:06 +00:00
|
|
|
doctextrunner "queryorchestration/api/docTextRunner"
|
|
|
|
|
documenttext "queryorchestration/internal/document/text"
|
|
|
|
|
"queryorchestration/internal/server/runner"
|
2025-09-18 21:06:21 +00:00
|
|
|
"queryorchestration/internal/serviceconfig/build"
|
2025-04-02 18:50:03 +00:00
|
|
|
"queryorchestration/internal/serviceconfig/objectstore"
|
2025-02-07 14:15:06 +00:00
|
|
|
"queryorchestration/internal/serviceconfig/queue/querysync"
|
2025-03-20 11:06:41 +00:00
|
|
|
"queryorchestration/internal/serviceconfig/textract"
|
2025-02-07 14:15:06 +00:00
|
|
|
|
|
|
|
|
_ "github.com/lib/pq"
|
|
|
|
|
)
|
|
|
|
|
|
2025-06-10 12:57:30 +00:00
|
|
|
type DocTextConfig struct {
|
2025-04-02 18:50:03 +00:00
|
|
|
runner.BaseConfig[doctextrunner.Body]
|
2025-03-20 11:06:41 +00:00
|
|
|
textract.TextractConfig
|
2025-04-02 18:50:03 +00:00
|
|
|
querysync.QuerySyncConfig
|
|
|
|
|
objectstore.ObjectStoreConfig
|
2025-02-07 14:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func main() {
|
2025-09-18 21:06:21 +00:00
|
|
|
// Print version information before any environment checks
|
|
|
|
|
build.PrintVersionInfo("docTextRunner")
|
|
|
|
|
|
2025-02-07 14:15:06 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
2025-06-10 12:57:30 +00:00
|
|
|
cfg := &DocTextConfig{}
|
2025-02-07 14:15:06 +00:00
|
|
|
|
2025-04-02 18:50:03 +00:00
|
|
|
cfg.ControllerFunc = func() runner.Controller[doctextrunner.Body] {
|
2025-03-11 18:15:49 +00:00
|
|
|
text := documenttext.New(cfg)
|
2025-02-07 14:15:06 +00:00
|
|
|
|
2025-04-22 14:40:16 +00:00
|
|
|
return doctextrunner.New(&doctextrunner.Services{
|
2025-02-07 14:15:06 +00:00
|
|
|
Text: text,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server, err := runner.New(ctx, cfg)
|
|
|
|
|
if err != nil {
|
|
|
|
|
slog.Error(err.Error())
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-22 14:40:16 +00:00
|
|
|
err = cfg.SetStoreClient(ctx)
|
|
|
|
|
if err != nil {
|
|
|
|
|
slog.Error(err.Error())
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-02 18:50:03 +00:00
|
|
|
err = cfg.SetTextractClient(ctx)
|
|
|
|
|
if err != nil {
|
|
|
|
|
slog.Error(err.Error())
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-07 14:15:06 +00:00
|
|
|
server.Listen(ctx)
|
|
|
|
|
}
|