diff options
author | George Goldberg <george@gberg.me> | 2017-07-11 09:09:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-11 09:09:15 +0100 |
commit | 83d53ea98cf5486f89bd4280b6b5ef835da4fd22 (patch) | |
tree | 1977949d599b3ce3b023f8699854d974be4d92a8 /jobs/workers.go | |
parent | 0cc60abf6a33dca0d8317481f83d0eb2771f43a1 (diff) | |
download | chat-83d53ea98cf5486f89bd4280b6b5ef835da4fd22.tar.gz chat-83d53ea98cf5486f89bd4280b6b5ef835da4fd22.tar.bz2 chat-83d53ea98cf5486f89bd4280b6b5ef835da4fd22.zip |
PLT-6475: Elasticsearch Indexing Worker. (#6879)
Diffstat (limited to 'jobs/workers.go')
-rw-r--r-- | jobs/workers.go | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/jobs/workers.go b/jobs/workers.go index a42ec4607..bb80ad79a 100644 --- a/jobs/workers.go +++ b/jobs/workers.go @@ -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") |