0b74e9ad23
continuous-integration/drone/push Build is passing
- Introduced a new `RecommendedTendersPageCacheRefresher` interface to manage the asynchronous refresh of recommendation pages in Redis, improving cache management. - Updated the `companyService` to support setting page cache languages and refreshing the recommended tenders page cache based on company IDs. - Enhanced the `tenderService` to build and invalidate recommended tenders page caches, ensuring timely updates and efficient retrieval of cached recommendations. - Added configuration options for recommendation page cache languages in the `AISummarizerConfig`, allowing for flexible language support. - Implemented unit tests for the new caching logic and page refresh functionality, ensuring robust validation of the recommendation caching process. This update significantly improves the efficiency and responsiveness of the tender recommendation service by integrating enhanced caching mechanisms and page refresh capabilities.
95 lines
4.1 KiB
Go
95 lines
4.1 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"time"
|
|
"tm/pkg/config"
|
|
)
|
|
|
|
// Config holds configuration for the web command
|
|
type Config struct {
|
|
Server config.ServerConfig
|
|
Database config.DatabaseConfig
|
|
Cache config.CacheConfig
|
|
Logging config.LoggingConfig
|
|
RateLimit config.RateLimitConfig
|
|
Assets config.AssetsConfig
|
|
Notification config.NotificationConfig
|
|
Ollama config.OllamaConfig
|
|
HCaptcha config.HCaptchaConfig
|
|
Scraper ScraperConfig
|
|
TED TEDConfig
|
|
UserAuth AuthConfig
|
|
CustomerAuth AuthConfig
|
|
DocumentScraper DocumentScraperConfig
|
|
AISummarizer AISummarizerConfig
|
|
GoRules GoRulesConfig
|
|
Elasticsearch config.ElasticsearchConfig
|
|
}
|
|
|
|
type ScraperConfig struct {
|
|
BaseURL string `env:"SCRAPER_BASE_URL"`
|
|
Timeout time.Duration `env:"SCRAPER_TIMEOUT"`
|
|
}
|
|
|
|
// TEDConfig holds configuration for TED scraper (one-time scraping from admin panel)
|
|
type TEDConfig struct {
|
|
BaseURL string `env:"TED_BASE_URL" envDefault:"https://ted.europa.eu"`
|
|
Timeout time.Duration `env:"TED_TIMEOUT" envDefault:"30s"`
|
|
MaxRetries int `env:"TED_MAX_RETRIES" envDefault:"3"`
|
|
RetryDelay time.Duration `env:"TED_RETRY_DELAY" envDefault:"5s"`
|
|
UserAgent string `env:"TED_USER_AGENT" envDefault:"TM-TED-Scraper/1.0"`
|
|
MaxConcurrency int `env:"TED_MAX_CONCURRENCY" envDefault:"5"`
|
|
DownloadDir string `env:"TED_DOWNLOAD_DIR" envDefault:"./downloads"`
|
|
CleanupAfter time.Duration `env:"TED_CLEANUP_AFTER" envDefault:"24h"`
|
|
ScrapingInterval string `env:"TED_SCRAPING_INTERVAL" envDefault:"* * 10 * * *"`
|
|
MaxNoticesPerDay int `env:"TED_MAX_NOTICES_PER_DAY" envDefault:"0"`
|
|
AlertMail string `env:"ALERT_MAIL" envDefault:"alerts@opplens.com"`
|
|
}
|
|
|
|
type AuthConfig struct {
|
|
JWT JWTConfig
|
|
}
|
|
|
|
type JWTConfig struct {
|
|
AccessSecret string `env:"USER_AUTH_ACCESS_SECRET"`
|
|
RefreshSecret string `env:"USER_AUTH_REFRESH_SECRET"`
|
|
AccessExpiresIn int `env:"USER_AUTH_ACCESS_EXPIRES_IN"`
|
|
RefreshExpiresIn int `env:"USER_AUTH_REFRESH_EXPIRES_IN"`
|
|
}
|
|
|
|
// DocumentScraperConfig holds configuration for the external document scraper service API
|
|
type DocumentScraperConfig struct {
|
|
APIKey string `env:"DOCUMENT_SCRAPER_API_KEY" envDefault:""`
|
|
}
|
|
|
|
// AISummarizerConfig holds configuration for the external AI summarizer service
|
|
type AISummarizerConfig struct {
|
|
// HTTP API settings
|
|
APIBaseURL string `env:"AI_SUMMARIZER_API_BASE_URL" envDefault:""`
|
|
APITimeout time.Duration `env:"AI_SUMMARIZER_API_TIMEOUT" envDefault:"120s"`
|
|
APIRetryCount int `env:"AI_SUMMARIZER_API_RETRY_COUNT" envDefault:"2"`
|
|
APIRetryDelay time.Duration `env:"AI_SUMMARIZER_API_RETRY_DELAY" envDefault:"3s"`
|
|
DefaultLanguage string `env:"AI_SUMMARIZER_DEFAULT_LANGUAGE" envDefault:"en"`
|
|
// RecommendationCacheTTL is an optional max Redis TTL for cached recommendations.
|
|
// When 0 (default), entries persist until the company is created, updated, or onboarded.
|
|
RecommendationCacheTTL time.Duration `env:"AI_RECOMMENDATION_CACHE_TTL" envDefault:"0"`
|
|
// RecommendationPageCacheLanguages lists languages pre-built for the recommendation page cache.
|
|
RecommendationPageCacheLanguages string `env:"AI_RECOMMENDATION_PAGE_CACHE_LANGUAGES" envDefault:"en"`
|
|
|
|
// MinIO storage settings
|
|
MinioEndpoint string `env:"AI_SUMMARIZER_MINIO_ENDPOINT" envDefault:""`
|
|
MinioAccessKey string `env:"AI_SUMMARIZER_MINIO_ACCESS_KEY" envDefault:""`
|
|
MinioSecretKey string `env:"AI_SUMMARIZER_MINIO_SECRET_KEY" envDefault:""`
|
|
MinioUseSSL bool `env:"AI_SUMMARIZER_MINIO_USE_SSL" envDefault:"false"`
|
|
MinioRegion string `env:"AI_SUMMARIZER_MINIO_REGION" envDefault:"us-east-1"`
|
|
MinioBucket string `env:"AI_SUMMARIZER_MINIO_BUCKET" envDefault:"opplens"`
|
|
}
|
|
|
|
// GoRulesConfig holds configuration for the GoRules status engine.
|
|
type GoRulesConfig struct {
|
|
BaseURL string `env:"GORULES_BASE_URL"`
|
|
Token string `env:"GORULES_TOKEN"`
|
|
RuleID string `env:"GORULES_RULE_ID"`
|
|
Timeout time.Duration `env:"GORULES_TIMEOUT"`
|
|
}
|