ab28cf30db
Add common metrics * add common metrics and sample for using * updates * attempt integration * wip * working stubs generate * docs * comments * Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/common-metrics * runner metrics all * exclude generated from the coverage * fix lint * refactor metrics * change .gen filename * new gen * Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/common-metrics * docs * main merge * refactor * add to generate * merge main
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"os"
|
|
|
|
docinitrunner "queryorchestration/api/docInitRunner"
|
|
documentinit "queryorchestration/internal/document/init"
|
|
"queryorchestration/internal/server/runner"
|
|
documentsyncc "queryorchestration/internal/serviceconfig/queue/documentsync"
|
|
|
|
_ "github.com/lib/pq"
|
|
)
|
|
|
|
type DocInitConfig struct {
|
|
runner.BaseConfig
|
|
documentsyncc.DocSyncConfig
|
|
}
|
|
|
|
func main() {
|
|
ctx := context.Background()
|
|
|
|
cfg := &DocInitConfig{}
|
|
|
|
cfg.ControllerFunc = func() runner.Controller {
|
|
docinit := documentinit.New(cfg)
|
|
|
|
return docinitrunner.New(cfg.GetValidator(), &docinitrunner.Services{
|
|
Document: docinit,
|
|
})
|
|
}
|
|
|
|
server, err := runner.New(ctx, cfg)
|
|
if err != nil {
|
|
slog.Error(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
|
|
// optional add shutdown metrics
|
|
defer func() {
|
|
err = cfg.GetMetrics().RecordLifecycleEvent(1.0, "shutdown", "main")
|
|
|
|
if err != nil {
|
|
slog.Error("Failed to record shutdown metric ", "error", err)
|
|
}
|
|
}()
|
|
|
|
// start and block until server is done
|
|
server.Listen(ctx)
|
|
|
|
// optional shutdown
|
|
metrics := cfg.GetMetrics()
|
|
if err := metrics.Shutdown(ctx); err != nil {
|
|
slog.Error("Error shutting down metrics server", "error", err)
|
|
}
|
|
}
|