Merged in feature/serviceconfig-integration (pull request #38)
DRAFT PR : WIP working through ideas for integration * movearound * attempttwo * openapi * further sanding * fix * start on tests * runthroughsingleconfig * somechanges * reflectissue * removeerrs * mostlyremovepanic * removeenv * noncfgtests * go * repo * fix service config test * add PWD to all * test fix * fix lint * todo for later * passingunittests * alltests * testlogger * testloggername * clean
This commit is contained in:
+32
-20
@@ -2,9 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
queryservice "queryorchestration/api/queryService"
|
||||
"queryorchestration/internal/client"
|
||||
"queryorchestration/internal/document"
|
||||
documentclean "queryorchestration/internal/document/clean"
|
||||
documenttext "queryorchestration/internal/document/text"
|
||||
"queryorchestration/internal/export"
|
||||
@@ -12,32 +15,41 @@ import (
|
||||
"queryorchestration/internal/job/collector"
|
||||
"queryorchestration/internal/query"
|
||||
"queryorchestration/internal/query/result"
|
||||
"queryorchestration/internal/server"
|
||||
"queryorchestration/internal/server/api"
|
||||
service "queryorchestration/internal/server/service"
|
||||
"queryorchestration/internal/serviceconfig"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
|
||||
registerHandlers := func(cfg *server.Config, e *echo.Echo) *api.APIConfig {
|
||||
exp := export.New(cfg.Database)
|
||||
cfg := &service.BaseConfig{}
|
||||
|
||||
if err := serviceconfig.InitializeConfig(cfg); err != nil {
|
||||
fmt.Printf("Error initializing config: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cfg.RegisterHandlersFunc = func() (*openapi3.T, error) {
|
||||
exp := export.New()
|
||||
extract := documenttext.New()
|
||||
clean := documentclean.New()
|
||||
col := collector.New(cfg.Database, &collector.Services{
|
||||
res := result.New(cfg)
|
||||
col := collector.New(cfg, &collector.Services{
|
||||
Text: extract,
|
||||
Clean: clean,
|
||||
})
|
||||
res := result.New(cfg.Database)
|
||||
que := query.New(cfg.Database, &query.Services{
|
||||
doc := document.New(cfg)
|
||||
que := query.New(cfg, &query.Services{
|
||||
Text: extract,
|
||||
Result: res,
|
||||
Collector: col,
|
||||
Document: doc,
|
||||
})
|
||||
cli := client.New(cfg.Database)
|
||||
jbb := job.New(cfg.Database, &job.Services{
|
||||
cli := client.New(cfg)
|
||||
jbb := job.New(cfg, &job.Services{
|
||||
Collector: col,
|
||||
Client: cli,
|
||||
})
|
||||
@@ -50,23 +62,23 @@ func main() {
|
||||
Job: jbb,
|
||||
}
|
||||
|
||||
cons := queryservice.NewControllers(cfg.Validator, services)
|
||||
cons := queryservice.NewControllers(cfg.GetValidator(), services)
|
||||
|
||||
queryservice.RegisterHandlersWithBaseURL(e, cons, "")
|
||||
queryservice.RegisterHandlersWithBaseURL(cfg.Router, cons, "")
|
||||
|
||||
swagger, err := queryservice.GetSwagger()
|
||||
if err != nil {
|
||||
log.Panicf("Error loading swagger: %s", err)
|
||||
return nil, fmt.Errorf("error loading swagger: %s", err)
|
||||
}
|
||||
|
||||
return &api.APIConfig{
|
||||
Swagger: swagger,
|
||||
}
|
||||
return swagger, nil
|
||||
}
|
||||
|
||||
server := api.New(ctx, &api.Config{
|
||||
RegisterHandlers: registerHandlers,
|
||||
})
|
||||
server, err := service.New(ctx, cfg)
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
server.Listen()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user