Files
query-orchestration/cmd/queryService/main.go
T
Michael McGuinness 0af049e96f Merged in feature/docGen (pull request #88)
Basic Generate

* basicgenerate

* basic
2025-03-05 13:50:43 +00:00

120 lines
3.4 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 jobs for a client will be in reference to the respective client.
//
// - Job - A job is a single instance of requirements for a client. This maintains a set of queries and processes in relation to itself.
//
// - Collector - A collector specifies the required queries for export for a given job.
//
// - Sample - A sample is a subset of documents to be used for testing. When it is active a job 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 job to a given location.
package main
import (
"context"
"fmt"
"log/slog"
"os"
queryservice "queryorchestration/api/queryService"
"queryorchestration/internal/client"
"queryorchestration/internal/document"
cleanversion "queryorchestration/internal/document/clean/version"
textversion "queryorchestration/internal/document/text/version"
"queryorchestration/internal/export"
"queryorchestration/internal/job"
"queryorchestration/internal/job/collector"
collectorupdate "queryorchestration/internal/job/collector/update"
"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/jobsync"
"queryorchestration/internal/serviceconfig/queue/queryversionsync"
"github.com/getkin/kin-openapi/openapi3"
_ "github.com/lib/pq"
)
type QueryServiceConfig struct {
service.BaseConfig
jobsync.JobSyncConfig
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, &collector.Services{
CleanVersion: clv,
TextVersion: tev,
})
colupdate := collectorupdate.New(cfg, &collectorupdate.Services{
Collector: col,
CleanVersion: clv,
TextVersion: tev,
})
cli := client.New(cfg)
jbb := job.New(cfg, &job.Services{
Client: cli,
Collector: col,
})
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,
CollectorUpdate: colupdate,
Query: que,
QueryUpdate: qupdate,
QueryTest: quetest,
Client: cli,
Job: jbb,
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()
}