Files
query-orchestration/cmd/queryService/main.go
T
Michael McGuinness ed8cfbbee4 Merged in feature/collectorset (pull request #96)
Set Collector

* set
2025-03-10 13:00:57 +00:00

109 lines
3.1 KiB
Go

// This API currently manages all user entities to be managed. This allows users of the service to change required entities and processes.
//
// The entities in question:
//
// - Client - A client is a single client of the Doczy project, all configurations and clients for a client will be in reference to the respective client.
//
// - Collector - A collector specifies the required queries for export for a given client.
//
// - Sample - A sample is a subset of documents to be used for testing. When it is active a client will only process documents in the sample.
//
// - Query - A query is a block of processing of data which takes an input and produces an output.
//
// - Export - An export is a manually started process which outputs the results for a client to a given location.
package main
import (
"context"
"fmt"
"log/slog"
"os"
queryservice "queryorchestration/api/queryService"
"queryorchestration/internal/client"
"queryorchestration/internal/collector"
collectorset "queryorchestration/internal/collector/set"
"queryorchestration/internal/document"
cleanversion "queryorchestration/internal/document/clean/version"
textversion "queryorchestration/internal/document/text/version"
"queryorchestration/internal/export"
"queryorchestration/internal/query"
"queryorchestration/internal/query/result"
querytest "queryorchestration/internal/query/test"
queryupdate "queryorchestration/internal/query/update"
service "queryorchestration/internal/server/service"
"queryorchestration/internal/serviceconfig/queue/clientsync"
"queryorchestration/internal/serviceconfig/queue/queryversionsync"
"github.com/getkin/kin-openapi/openapi3"
_ "github.com/lib/pq"
)
type QueryServiceConfig struct {
service.BaseConfig
clientsync.ClientSyncConfig
queryversionsync.QueryVersionSyncConfig
}
func main() {
ctx := context.Background()
cfg := &QueryServiceConfig{}
cfg.RegisterHandlersFunc = func() (*openapi3.T, error) {
exp := export.New()
que := query.New(cfg)
res := result.New(cfg, &result.Services{
Query: que,
})
tev := textversion.New(cfg)
clv := cleanversion.New(cfg)
col := collector.New(cfg)
colupdate := collectorset.New(cfg, &collectorset.Services{
Collector: col,
CleanVersion: clv,
TextVersion: tev,
})
cli := client.New(cfg)
doc := document.New(cfg)
quetest := querytest.New(cfg, &querytest.Services{
Collector: col,
Result: res,
Document: doc,
})
qupdate := queryupdate.New(cfg, &queryupdate.Services{
Query: que,
})
services := &queryservice.Services{
Export: exp,
Collector: col,
CollectorSet: colupdate,
Query: que,
QueryUpdate: qupdate,
QueryTest: quetest,
Client: cli,
Document: doc,
}
cons := queryservice.NewControllers(cfg.GetValidator(), services)
queryservice.RegisterHandlers(cfg.Router, cons)
swagger, err := queryservice.GetSwagger()
if err != nil {
return nil, fmt.Errorf("error loading swagger: %s", err)
}
return swagger, nil
}
server, err := service.New(ctx, cfg)
if err != nil {
slog.Error(err.Error())
os.Exit(1)
}
server.Listen()
}