rename config variable

This commit is contained in:
Cyberes 2024-03-17 20:32:12 -06:00
parent b70c830d18
commit 6a7153b92b
5 changed files with 9 additions and 9 deletions

View File

@ -41,7 +41,7 @@ func APIAdminCrawlsInfo(w http.ResponseWriter, r *http.Request) {
// If no sync is running then these vars will not exist.
elasticWorkers = map[string]interface{}{
"busy": globals.ElasticCrawlers.BusyWorkers,
"alive": config.GetConfig().ElasticsearchSyncThreads,
"alive": config.GetConfig().ElasticsearchSyncWorkers,
"queueSize": globals.ElasticCrawlers.Queue.GetQueuedJobs(),
}
} else {

View File

@ -37,7 +37,7 @@ type Config struct {
ElasticsearchFullSyncInterval int
ElasticsearchAPIKey string
ElasticsearchIndex string
ElasticsearchSyncThreads int
ElasticsearchSyncWorkers int
ElasticsearchExcludePatterns []string
ElasticsearchFullSyncOnStart bool
ElasticsearchDefaultQueryField string
@ -83,7 +83,7 @@ func SetConfig(configFile string) (*Config, error) {
viper.SetDefault("elasticsearch_full_sync_interval", 86400)
viper.SetDefault("elasticsearch_api_key", "")
viper.SetDefault("elasticsearch_index", "crazyfs_search")
viper.SetDefault("elasticsearch_sync_threads", 50)
viper.SetDefault("elasticsearch_sync_workers", 50)
viper.SetDefault("elasticsearch_exclude_patterns", []string{".git"})
viper.SetDefault("elasticsearch_allow_concurrent_syncs", false)
viper.SetDefault("elasticsearch_full_sync_on_start", false)
@ -139,7 +139,7 @@ func SetConfig(configFile string) (*Config, error) {
ElasticsearchFullSyncInterval: viper.GetInt("elasticsearch_full_sync_interval"),
ElasticsearchAPIKey: viper.GetString("elasticsearch_api_key"),
ElasticsearchIndex: viper.GetString("elasticsearch_index"),
ElasticsearchSyncThreads: viper.GetInt("elasticsearch_sync_threads"),
ElasticsearchSyncWorkers: viper.GetInt("elasticsearch_sync_workers"),
ElasticsearchExcludePatterns: viper.GetStringSlice("elasticsearch_exclude_patterns"),
ElasticsearchFullSyncOnStart: viper.GetBool("elasticsearch_full_sync_on_start"),
ElasticsearchDefaultQueryField: viper.GetString("elasticsearch_default_query_field"),

View File

@ -116,14 +116,14 @@ func main() {
// Start the Elastic connection, so it can initialize while we're doing the initial crawl.
// If we fail to establish a connection to Elastic, don't kill the entire server. Instead, just disable Elastic.
if cfg.ElasticsearchEnable && !cliArgs.disableElasticSync {
fmt.Println(config.GetConfig().ElasticsearchSyncThreads + 1)
fmt.Println(config.GetConfig().ElasticsearchSyncWorkers + 1)
esCfg := elasticsearch.Config{
Addresses: []string{
cfg.ElasticsearchEndpoint,
},
APIKey: cfg.ElasticsearchAPIKey,
//Transport: &http.Transport{
// MaxIdleConnsPerHost: config.GetConfig().ElasticsearchSyncThreads + 1,
// MaxIdleConnsPerHost: config.GetConfig().ElasticsearchSyncWorkers + 1,
// IdleConnTimeout: 30 * time.Second,
//},
}

View File

@ -25,7 +25,7 @@ func InitializeElasticCrawlerWorkers() *globals.DcWorkers {
if globals.ElasticCrawlers != nil {
panic("ElasticCrawlers has already been defined!")
}
elWorkers := workers.InitializeWorkers(config.GetConfig().ElasticsearchSyncThreads, elasticDeleteWorker)
elWorkers := workers.InitializeWorkers(config.GetConfig().ElasticsearchSyncWorkers, elasticDeleteWorker)
d := &globals.DcWorkers{}
d.Queue = elWorkers.Queue
extra := make(map[string]interface{})
@ -34,7 +34,7 @@ func InitializeElasticCrawlerWorkers() *globals.DcWorkers {
d.Extra = &CrawlerExtras{}
elWorkers.BusyWorkers = &d.BusyWorkers
globals.ElasticCrawlers = d
log.Debugf("CRAWLERS - Started %d Elasticsearch sync workers.", config.GetConfig().ElasticsearchSyncThreads)
log.Debugf("CRAWLERS - Started %d Elasticsearch sync workers.", config.GetConfig().ElasticsearchSyncWorkers)
return d
}

View File

@ -150,7 +150,7 @@ func EnableElasticsearchConnection() {
return
}
Enabled = true
//http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = config.GetConfig().ElasticsearchSyncThreads
//http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = config.GetConfig().ElasticsearchSyncWorkers
log.Infof(`ELASTIC - Connected to index "%s".`, config.GetConfig().ElasticsearchIndex)
}