Get tender timeout fix
This commit is contained in:
@@ -56,6 +56,8 @@ type tenderService struct {
|
||||
defaultLanguage string
|
||||
}
|
||||
|
||||
const aiSummaryEnrichmentTimeout = 2 * time.Second
|
||||
|
||||
// NewService creates a new tender service
|
||||
func NewService(repository TenderRepository, companyService company.Service, customerService customer.Service, logger logger.Logger, aiClient AISummarizerClient, aiStorage AISummarizerStorage, defaultLanguage string) Service {
|
||||
if strings.TrimSpace(defaultLanguage) == "" {
|
||||
@@ -109,7 +111,11 @@ func (s *tenderService) enrichWithAISummary(ctx context.Context, resp *TenderRes
|
||||
return
|
||||
}
|
||||
|
||||
summary, err := s.aiSummarizerStorage.GetSummaryFromStorage(ctx, resp.NoticePublicationID)
|
||||
// Keep tender detail response fast even if AI storage is slow/unreachable.
|
||||
enrichCtx, cancel := context.WithTimeout(ctx, aiSummaryEnrichmentTimeout)
|
||||
defer cancel()
|
||||
|
||||
summary, err := s.aiSummarizerStorage.GetSummaryFromStorage(enrichCtx, resp.NoticePublicationID)
|
||||
if err != nil {
|
||||
s.logger.Debug("AI summary not available for tender", map[string]interface{}{
|
||||
"tender_id": resp.ID,
|
||||
|
||||
Reference in New Issue
Block a user