2025-03-05 13:50:43 +00:00
// 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.
2024-12-18 18:54:48 +00:00
package main
import (
"context"
2025-01-31 13:43:55 +00:00
"fmt"
"log/slog"
"os"
2025-03-05 12:05:46 +00:00
2025-01-15 19:45:51 +00:00
queryservice "queryorchestration/api/queryService"
2025-01-21 18:24:14 +00:00
"queryorchestration/internal/client"
2025-01-31 13:43:55 +00:00
"queryorchestration/internal/document"
2025-02-12 19:00:25 +00:00
cleanversion "queryorchestration/internal/document/clean/version"
textversion "queryorchestration/internal/document/text/version"
2024-12-24 17:13:48 +00:00
"queryorchestration/internal/export"
2025-01-24 14:52:56 +00:00
"queryorchestration/internal/job"
2025-01-17 12:00:32 +00:00
"queryorchestration/internal/job/collector"
2025-02-12 19:00:25 +00:00
collectorupdate "queryorchestration/internal/job/collector/update"
2024-12-24 17:13:48 +00:00
"queryorchestration/internal/query"
2025-01-29 11:52:37 +00:00
"queryorchestration/internal/query/result"
2025-02-11 15:22:59 +00:00
querytest "queryorchestration/internal/query/test"
2025-02-14 10:56:24 +00:00
queryupdate "queryorchestration/internal/query/update"
2025-01-31 13:43:55 +00:00
service "queryorchestration/internal/server/service"
2025-02-12 19:00:25 +00:00
"queryorchestration/internal/serviceconfig/queue/jobsync"
2025-02-14 10:56:24 +00:00
"queryorchestration/internal/serviceconfig/queue/queryversionsync"
2024-12-18 18:54:48 +00:00
2025-01-31 13:43:55 +00:00
"github.com/getkin/kin-openapi/openapi3"
2024-12-18 18:54:48 +00:00
_ "github.com/lib/pq"
)
2025-02-12 19:00:25 +00:00
type QueryServiceConfig struct {
service . BaseConfig
jobsync . JobSyncConfig
2025-02-14 10:56:24 +00:00
queryversionsync . QueryVersionSyncConfig
2025-02-12 19:00:25 +00:00
}
2024-12-18 18:54:48 +00:00
func main ( ) {
ctx := context . Background ( )
2025-02-12 19:00:25 +00:00
cfg := & QueryServiceConfig { }
2025-01-31 13:43:55 +00:00
cfg . RegisterHandlersFunc = func ( ) ( * openapi3 . T , error ) {
exp := export . New ( )
2025-02-11 15:22:59 +00:00
que := query . New ( cfg )
res := result . New ( cfg , & result . Services {
Query : que ,
} )
2025-02-12 19:00:25 +00:00
tev := textversion . New ( cfg )
clv := cleanversion . New ( cfg )
2025-01-31 13:43:55 +00:00
col := collector . New ( cfg , & collector . Services {
2025-02-12 19:00:25 +00:00
CleanVersion : clv ,
TextVersion : tev ,
2025-01-29 11:52:37 +00:00
} )
2025-02-12 19:00:25 +00:00
colupdate := collectorupdate . New ( cfg , & collectorupdate . Services {
Collector : col ,
CleanVersion : clv ,
TextVersion : tev ,
2025-01-23 14:56:20 +00:00
} )
2025-01-31 13:43:55 +00:00
cli := client . New ( cfg )
jbb := job . New ( cfg , & job . Services {
2025-01-24 14:52:56 +00:00
Client : cli ,
2025-02-12 19:00:25 +00:00
Collector : col ,
} )
doc := document . New ( cfg )
quetest := querytest . New ( cfg , & querytest . Services {
Collector : col ,
Result : res ,
Document : doc ,
2025-01-24 14:52:56 +00:00
} )
2025-02-14 10:56:24 +00:00
qupdate := queryupdate . New ( cfg , & queryupdate . Services {
Query : que ,
} )
2024-12-18 18:54:48 +00:00
2025-01-15 19:45:51 +00:00
services := & queryservice . Services {
2025-02-12 19:00:25 +00:00
Export : exp ,
Collector : col ,
CollectorUpdate : colupdate ,
Query : que ,
2025-02-14 10:56:24 +00:00
QueryUpdate : qupdate ,
QueryTest : quetest ,
2025-02-12 19:00:25 +00:00
Client : cli ,
Job : jbb ,
2025-02-21 17:05:37 +00:00
Document : doc ,
2025-01-15 19:45:51 +00:00
}
2025-01-31 13:43:55 +00:00
cons := queryservice . NewControllers ( cfg . GetValidator ( ) , services )
2025-01-15 19:45:51 +00:00
2025-02-05 12:52:41 +00:00
queryservice . RegisterHandlers ( cfg . Router , cons )
2025-01-15 19:45:51 +00:00
swagger , err := queryservice . GetSwagger ( )
if err != nil {
2025-01-31 13:43:55 +00:00
return nil , fmt . Errorf ( "error loading swagger: %s" , err )
2025-01-15 19:45:51 +00:00
}
2025-01-31 13:43:55 +00:00
return swagger , nil
2024-12-18 18:54:48 +00:00
}
2025-01-31 13:43:55 +00:00
server , err := service . New ( ctx , cfg )
if err != nil {
slog . Error ( err . Error ( ) )
os . Exit ( 1 )
}
2024-12-18 18:54:48 +00:00
2025-01-10 11:12:03 +00:00
server . Listen ( )
2024-12-18 18:54:48 +00:00
}