Files
query-orchestration/cmd/queryRunner/main.go
T
Jay Brown a6e081e5cd Merged in feature/log-version (pull request #185)
inject and print version at startup for all services

* inject and print version

* coverage
2025-09-18 21:06:21 +00:00

67 lines
1.4 KiB
Go

// **Listens For**: Body Containing Document ID and Query ID
//
// **Action**.
//
// Run the query for the given document and store the result.
//
// Events with the document id and downstream query ids are pushed to the QUERY queue.
package main
import (
"context"
"log/slog"
"os"
queryrunner "queryorchestration/api/queryRunner"
"queryorchestration/internal/query"
"queryorchestration/internal/query/result"
resultset "queryorchestration/internal/query/result/set"
resultsync "queryorchestration/internal/query/result/sync"
"queryorchestration/internal/server/runner"
"queryorchestration/internal/serviceconfig/build"
queryc "queryorchestration/internal/serviceconfig/queue/query"
_ "github.com/lib/pq"
)
type QueryConfig struct {
runner.BaseConfig[queryrunner.Body]
queryc.QueryConfig
}
func main() {
// Print version information before any environment checks
build.PrintVersionInfo("queryRunner")
ctx := context.Background()
cfg := &QueryConfig{}
cfg.ControllerFunc = func() runner.Controller[queryrunner.Body] {
que := query.New(cfg)
res := result.New(cfg, &result.Services{
Query: que,
})
sync := resultsync.New(cfg)
resset := resultset.New(cfg, &resultset.Services{
Result: res,
Query: que,
Sync: sync,
})
c := queryrunner.New(&queryrunner.Services{
ResultSet: resset,
})
return &c
}
server, err := runner.New(ctx, cfg)
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}
server.Listen(ctx)
}