diff --git a/cmd/worker/bootstrap/bootstrap.go b/cmd/worker/bootstrap/bootstrap.go index 9fd3bab..f37f58b 100644 --- a/cmd/worker/bootstrap/bootstrap.go +++ b/cmd/worker/bootstrap/bootstrap.go @@ -223,7 +223,8 @@ func InitGLMService(conf GLMConfig, log logger.Logger) *glm.SDK { log.Error("Failed to initialize GLM SDK", map[string]interface{}{ "error": err.Error(), }) - panic(fmt.Sprintf("Failed to initialize GLM SDK: %v", err)) + log.Warn("GLM service will be disabled, translation features will not be available", map[string]interface{}{}) + return nil } log.Info("GLM SDK initialized successfully", map[string]interface{}{ diff --git a/cmd/worker/main.go b/cmd/worker/main.go index 65b8bbd..3a61b09 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -39,6 +39,11 @@ func main() { // Initialize GLM service glmService := bootstrap.InitGLMService(config.GLM, appLogger) + if glmService != nil { + appLogger.Info("GLM service initialized successfully", map[string]interface{}{}) + } else { + appLogger.Warn("GLM service not available, translation features will be disabled", map[string]interface{}{}) + } // Initialize scraper service scraperService := bootstrap.InitScraperService(*config, appLogger) diff --git a/cmd/worker/workers/notice.go b/cmd/worker/workers/notice.go index c35f6b6..b370072 100644 --- a/cmd/worker/workers/notice.go +++ b/cmd/worker/workers/notice.go @@ -392,28 +392,44 @@ func (w *NoticeWorker) ToTender(n *notice.Notice) (*tender.Tender, error) { } } - title, err := w.GLM.Translate(context.Background(), n.Title, n.NoticeLanguageCode, "en") - if err != nil { - w.Logger.Error("Failed to translate title", map[string]interface{}{ + var title string + if w.GLM != nil { + title, err = w.GLM.Translate(context.Background(), n.Title, n.NoticeLanguageCode, "en") + if err != nil { + w.Logger.Error("Failed to translate title", map[string]interface{}{ + "notice_publication_id": n.NoticePublicationID, + "country_code": n.CountryCode, + "content": n.Title, + "error": err.Error(), + }) + title = n.Title + } + } else { + w.Logger.Warn("GLM service not available, using original title", map[string]interface{}{ "notice_publication_id": n.NoticePublicationID, "country_code": n.CountryCode, - "content": n.Title, - "error": err.Error(), }) title = n.Title - // return err } - description, err := w.GLM.Translate(context.Background(), n.Description, n.NoticeLanguageCode, "en") - if err != nil { - w.Logger.Error("Failed to translate description", map[string]interface{}{ + var description string + if w.GLM != nil { + description, err = w.GLM.Translate(context.Background(), n.Description, n.NoticeLanguageCode, "en") + if err != nil { + w.Logger.Error("Failed to translate description", map[string]interface{}{ + "notice_publication_id": n.NoticePublicationID, + "country_code": n.CountryCode, + "content": n.Description, + "error": err.Error(), + }) + description = n.Description + } + } else { + w.Logger.Warn("GLM service not available, using original description", map[string]interface{}{ "notice_publication_id": n.NoticePublicationID, "country_code": n.CountryCode, - "content": n.Description, - "error": err.Error(), }) description = n.Description - // return err } t.Title = title t.Description = description