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