fixed glm panic
This commit is contained in:
@@ -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{}{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user