Additional echoes support

This commit is contained in:
Denis Zheleztsov 2018-11-08 14:50:15 +03:00
parent 0dc16c253e
commit 2ab75b4ed9

23
main.go
View File

@ -2,6 +2,7 @@ package main
import (
"flag"
"strings"
"strconv"
@ -11,13 +12,11 @@ import (
"gitea.difrex.ru/Umbrella/fetcher/idec"
)
var inode string
var offset int
var limit int
var all, reindex bool
var es string
var esIndex string
var esType string
var (
inode, es, esIndex, esType, addEchoes string
offset, limit int
all, reindex bool
)
// init ...
func init() {
@ -29,6 +28,7 @@ func init() {
flag.StringVar(&es, "es", "http://127.0.0.1:9200", "ES host")
flag.StringVar(&esIndex, "esindex", "idec", "ES index")
flag.StringVar(&esType, "estype", "post", "ES document type")
flag.StringVar(&addEchoes, "echoes", "", "Additional echoes to fetch. Comma separated")
flag.Parse()
}
@ -40,17 +40,20 @@ func main() {
log.Print("Working for node: ", inode)
// trying get echo list
var echoes []string
e, err := fc.GetEchoList()
if err != nil {
log.Error(err.Error())
fc.Echoes = []string{"ii.14", "linux.14"}
echoes = []string{"ii.14", "linux.14"}
} else {
var echoes []string
for _, echo := range e {
echoes = append(echoes, echo.Name)
}
fc.Echoes = echoes
}
if addEchoes != "" {
echoes = append(echoes, strings.Split(addEchoes, ",")...)
}
fc.Echoes = echoes
log.Print("Receive echoelist: ", fc.Echoes)