auto discovery (by consul)

This commit is contained in:
Michele Fadda 2018-11-22 12:29:08 +01:00
parent 58234ad80a
commit 5bc0076ecf
3 changed files with 36 additions and 3 deletions

30
consul.go Normal file
View file

@ -0,0 +1,30 @@
package main
import (
"fmt"
"log"
"strconv"
"strings"
"time"
"github.com/hashicorp/consul/api"
)
type Consul struct {
RedisTTL time.Duration
Timeout time.Duration
MaxError int
Influxdb string
Month string
Retention float64
MongoURI string
Database string
RedisURI string
}
func getClient() {
client, err := api.NewClient(api.DefaultConfig())
if err != nil {
panic(err)
}
}

View file

@ -14,7 +14,7 @@ import (
) )
const ( const (
_Version = "v4.4.5" _Version = "v5.0.0"
_Producer = 0 _Producer = 0
_Consumer = 1 _Consumer = 1
_Remover = 2 _Remover = 2

View file

@ -27,6 +27,7 @@ type Options struct {
Month string Month string
Queue int Queue int
Retention float64 Retention float64
Consul string
} }
var ( var (
@ -40,11 +41,12 @@ func usage() {
fmt.Println(`Usage: llmongo fmt.Println(`Usage: llmongo
-m <mongodb [ip:port,ip:port]> -m <mongodb [ip:port,ip:port]>
-d <mongodb database [dbname]> -d <mongodb database [dbname]>
-r <redisdb [ip:port]> -r <redisdb [ip:port]>
-t <redis keys ttl> -t <redis keys ttl>
-l <logfile> -l <logfile>
-T <running timeout> -T <running timeout>
-i <influxdb [localname@ip:port]> -i <influxdb [localname@ip:port]>
-C <consul [ip:port]>
-q <parallel consumer> -q <parallel consumer>
-R <retention> -R <retention>
-v <version> -v <version>
@ -69,6 +71,7 @@ func init() {
flag.StringVar(&dbs.Database, "d", "", "Mongodb Database") flag.StringVar(&dbs.Database, "d", "", "Mongodb Database")
flag.StringVar(&dbs.RedisURI, "r", "", "Redis") flag.StringVar(&dbs.RedisURI, "r", "", "Redis")
flag.StringVar(&opts.LogFile, "l", opts.LogFile, "Logs filename") flag.StringVar(&opts.LogFile, "l", opts.LogFile, "Logs filename")
flag.StringVar(&opts.Consul, "C", opts.Consul, "consul client")
flag.DurationVar(&opts.RedisTTL, "t", opts.RedisTTL, "Redis keys TTL") flag.DurationVar(&opts.RedisTTL, "t", opts.RedisTTL, "Redis keys TTL")
flag.BoolVar(&opts.Version, "v", false, "Version") flag.BoolVar(&opts.Version, "v", false, "Version")
flag.DurationVar(&opts.Timeout, "T", 0, "Running timeout") flag.DurationVar(&opts.Timeout, "T", 0, "Running timeout")