-
Notifications
You must be signed in to change notification settings - Fork 26
/
reindexer.go
54 lines (43 loc) · 1.11 KB
/
reindexer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package reindexer
import (
"sync"
"github.com/appbaseio/reactivesearch-api/middleware"
"github.com/appbaseio/reactivesearch-api/model/reindex"
"github.com/appbaseio/reactivesearch-api/plugins"
)
const (
logTag = "[reindexer]"
envEsURL = "ES_CLUSTER_URL"
typeName = "_doc"
)
var (
singleton *reindexer
once sync.Once
)
type reindexer struct {
}
// Use only this function to fetch the instance of user from within
// this package to avoid creating stateless duplicates of the plugin.
func Instance() *reindexer {
once.Do(func() { singleton = &reindexer{} })
return singleton
}
func (rx *reindexer) Name() string {
return logTag
}
func (rx *reindexer) InitFunc() error {
reindex.InitIndexAliasCache()
reindex.InitAliasIndexCache()
return nil
}
func (rx *reindexer) Routes() []plugins.Route {
return rx.routes()
}
// Default empty middleware array function
func (rx *reindexer) ESMiddleware() []middleware.Middleware {
return make([]middleware.Middleware, 0)
}
// Default empty middleware array function
func (rx *reindexer) RSMiddleware() []middleware.Middleware {
return make([]middleware.Middleware, 0)
}