- Updated comments and logging messages in the worker and related files to replace "daily-run" with "auto run" for clarity and consistency. - Adjusted the `WorkerConfig` struct to reflect the new terminology in configuration settings. - Renamed functions and test cases to align with the updated terminology, enhancing code readability and maintainability. This change improves the clarity of the AI pipeline's functionality within the tender management system.
This commit is contained in:
@@ -8,13 +8,13 @@ import (
|
||||
"tm/pkg/logger"
|
||||
)
|
||||
|
||||
// AIPipelineDailyWorker triggers the Opplens AI pipeline daily run (sync + full pipeline on newly synced tenders).
|
||||
// AIPipelineDailyWorker triggers the scheduled Opplens AI pipeline auto run.
|
||||
type AIPipelineDailyWorker struct {
|
||||
Logger logger.Logger
|
||||
AIClient *ai_summarizer.Client
|
||||
}
|
||||
|
||||
// NewAIPipelineDailyWorker creates a worker that calls POST /pipeline/daily-run on the AI service.
|
||||
// NewAIPipelineDailyWorker creates a worker that calls POST /pipeline/auto on the AI service.
|
||||
func NewAIPipelineDailyWorker(log logger.Logger, aiClient *ai_summarizer.Client) *AIPipelineDailyWorker {
|
||||
return &AIPipelineDailyWorker{
|
||||
Logger: log,
|
||||
@@ -22,28 +22,28 @@ func NewAIPipelineDailyWorker(log logger.Logger, aiClient *ai_summarizer.Client)
|
||||
}
|
||||
}
|
||||
|
||||
// Run starts the pipeline daily-run job. A 409 response means a run is already in progress and is returned as an error
|
||||
// Run starts the pipeline auto job. A 409 response means a run is already in progress and is returned as an error
|
||||
// so the daily job tracker does not mark today as completed before the run actually starts.
|
||||
func (w *AIPipelineDailyWorker) Run() error {
|
||||
if w.AIClient == nil {
|
||||
w.Logger.Warn("AI pipeline daily worker skipped: AI client is not configured", map[string]interface{}{})
|
||||
w.Logger.Warn("AI pipeline auto worker skipped: AI client is not configured", map[string]interface{}{})
|
||||
return nil
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
w.Logger.Info("AI pipeline daily worker started", map[string]interface{}{})
|
||||
w.Logger.Info("AI pipeline auto worker started", map[string]interface{}{})
|
||||
|
||||
resp, err := w.AIClient.PipelineDailyRun(ctx)
|
||||
resp, err := w.AIClient.PipelineAuto(ctx)
|
||||
if err != nil {
|
||||
w.Logger.Error("AI pipeline daily worker failed", map[string]interface{}{
|
||||
w.Logger.Error("AI pipeline auto worker failed", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
w.Logger.Info("AI pipeline daily worker triggered successfully", map[string]interface{}{
|
||||
w.Logger.Info("AI pipeline auto worker triggered successfully", map[string]interface{}{
|
||||
"status": resp.Status,
|
||||
"report": resp.Report,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user