Enhance worker configuration and error handling for AI summarizer
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Added `TranslationEnabled` and `TranslationInterval` fields to the worker configuration to manage automatic translation scheduling. - Updated the worker initialization to log when the translation worker is disabled. - Improved error handling in the AI summarizer client by introducing `APIStatusError` for better context on API failures, replacing direct error messages with structured error responses. This update enhances the configurability of the worker and improves error reporting for AI service interactions, contributing to better maintainability and user experience.
This commit is contained in:
@@ -85,6 +85,8 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
"notice_processing_limit": config.Worker.NoticeProcessingLimit,
|
||||
"notice_batch_pause": config.Worker.NoticeBatchPause.String(),
|
||||
"notice_fetch_error_backoff": config.Worker.NoticeFetchErrorBackoff.String(),
|
||||
"translation_enabled": config.Worker.TranslationEnabled,
|
||||
"translation_interval": config.Worker.TranslationInterval,
|
||||
})
|
||||
// Initialize repositories
|
||||
noticeRepo := notice.NewRepository(mongoManager, appLogger)
|
||||
@@ -138,7 +140,11 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
})
|
||||
|
||||
// Initialize translation backfill worker for configured languages
|
||||
if aiClient != nil {
|
||||
if !config.Worker.TranslationEnabled {
|
||||
appLogger.Info("Tender translation worker disabled by configuration", map[string]interface{}{
|
||||
"translation_enabled": false,
|
||||
})
|
||||
} else if aiClient != nil {
|
||||
targetLanguages := parseTranslationLanguages(config.AISummarizer)
|
||||
translationSuccessCounter := mongo.NewCounter(mongoManager)
|
||||
scheduler.AddJob(schedule.Job{
|
||||
|
||||
Reference in New Issue
Block a user