From ae76938f48ddcd1333361b8fd84fcd62ad7db9b9 Mon Sep 17 00:00:00 2001 From: Urko Date: Fri, 31 Mar 2023 13:05:36 +0200 Subject: [PATCH] feat: add missing xml tags --- cmd/server/main.go | 20 ++++++++++++++------ pkg/domain/employee_wi.go | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index acfcc17..1d9e79a 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -11,14 +11,18 @@ import ( "gitea.urkob.com/urko/ess-etl-go/internal/api/http" "gitea.urkob.com/urko/ess-etl-go/internal/services" "gitea.urkob.com/urko/ess-etl-go/pkg/adapter/repository/mongodb/employee_wi" + "gitea.urkob.com/urko/ess-etl-go/pkg/crono" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) func main() { + cr := crono.New() + defer cr.Table() cfg := config.NewConfig(".env") - ctx := context.Background() + ctx, cancel := context.WithCancel(signalContext(context.Background())) + defer cancel() dbOpts := options.Client() dbOpts.ApplyURI(cfg.DbAddress) @@ -41,12 +45,16 @@ func main() { NewRestServer(cfg). WithProfessionalHandler(services.NewEmployeeWIService(ctx, professionalRepo)) - if err = restServer.Start(cfg.ApiPort, ""); err != nil { - log.Fatalln("restServer.Start", err) - } + cr.MarkAndRestart("dependencies loaded") + go func() { + cr.Restart() + if err = restServer.Start(cfg.ApiPort, ""); err != nil { + log.Fatalln("restServer.Start", err) + cancel() + } + cr.MarkAndRestart("server up") + }() - ctx, cancel := context.WithCancel(signalContext(context.Background())) - defer cancel() <-ctx.Done() restServer.Shutdown() log.Println("gracefully shutdown") diff --git a/pkg/domain/employee_wi.go b/pkg/domain/employee_wi.go index 2d95d70..e2f0ad6 100644 --- a/pkg/domain/employee_wi.go +++ b/pkg/domain/employee_wi.go @@ -38,8 +38,8 @@ type EmployeeWorkInformation struct { EmployeeNumber int `xml:"EmployeeNumber" json:"employee_number" bson:"employee_number"` Date string `xml:"Date" json:"date"` WorkInformation WorkInfo `xml:"WorkInformation" json:"work_information" bson:"work_information"` - Baselines []Baseline `json:"baselines" bson:"baselines"` - CustomFields []CustomField `json:"custom_fields" bson:"custom_fields"` + Baselines []Baseline `xml:"Baselines>Baseline" json:"baselines" bson:"baselines"` + CustomFields []CustomField `xml:"CustomFields>CustomField" json:"custom_fields" bson:"custom_fields"` } type ArrayOfEmployeeWorkInformation struct {