PLT-6475: Elasticsearch Indexing Worker. (#6879)

Этот коммит содержится в:
George Goldberg
2017-07-11 09:09:15 +01:00
коммит произвёл GitHub
родитель 0cc60abf6a
Коммит 83d53ea98c
10 изменённых файлов: 216 добавлений и 31 удалений

Просмотреть файл

@@ -13,13 +13,13 @@ import (
)
type Workers struct {
startOnce sync.Once
watcher *Watcher
startOnce sync.Once
watcher *Watcher
DataRetention model.Worker
// SearchIndexing model.Job
DataRetention model.Worker
ElasticsearchIndexing model.Worker
listenerId string
listenerId string
}
func InitWorkers() *Workers {
@@ -32,6 +32,10 @@ func InitWorkers() *Workers {
workers.DataRetention = dataRetentionInterface.MakeWorker()
}
if elasticsearchIndexerInterface := ejobs.GetElasticsearchIndexerInterface(); elasticsearchIndexerInterface != nil {
workers.ElasticsearchIndexing = elasticsearchIndexerInterface.MakeWorker()
}
return workers
}
@@ -43,7 +47,9 @@ func (workers *Workers) Start() *Workers {
go workers.DataRetention.Run()
}
// go workers.SearchIndexing.Run()
if workers.ElasticsearchIndexing != nil && *utils.Cfg.ElasticSearchSettings.EnableIndexing {
go workers.ElasticsearchIndexing.Run()
}
go workers.watcher.Start()
})
@@ -61,6 +67,14 @@ func (workers *Workers) handleConfigChange(oldConfig *model.Config, newConfig *m
workers.DataRetention.Stop()
}
}
if workers.ElasticsearchIndexing != nil {
if !*oldConfig.ElasticSearchSettings.EnableIndexing && *newConfig.ElasticSearchSettings.EnableIndexing {
go workers.ElasticsearchIndexing.Run()
} else if *oldConfig.ElasticSearchSettings.EnableIndexing && !*newConfig.ElasticSearchSettings.EnableIndexing {
workers.ElasticsearchIndexing.Stop()
}
}
}
func (workers *Workers) Stop() *Workers {
@@ -71,7 +85,10 @@ func (workers *Workers) Stop() *Workers {
if workers.DataRetention != nil && *utils.Cfg.DataRetentionSettings.Enable {
workers.DataRetention.Stop()
}
// workers.SearchIndexing.Stop()
if workers.ElasticsearchIndexing != nil && *utils.Cfg.ElasticSearchSettings.EnableIndexing {
workers.ElasticsearchIndexing.Stop()
}
l4g.Info("Stopped workers")