auto discovery (by consul)
This commit is contained in:
parent
58234ad80a
commit
5bc0076ecf
3 changed files with 36 additions and 3 deletions
30
consul.go
Normal file
30
consul.go
Normal 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)
|
||||
}
|
||||
}
|
2
main.go
2
main.go
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
_Version = "v4.4.5"
|
||||
_Version = "v5.0.0"
|
||||
_Producer = 0
|
||||
_Consumer = 1
|
||||
_Remover = 2
|
||||
|
|
|
@ -27,6 +27,7 @@ type Options struct {
|
|||
Month string
|
||||
Queue int
|
||||
Retention float64
|
||||
Consul string
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -40,11 +41,12 @@ func usage() {
|
|||
fmt.Println(`Usage: llmongo
|
||||
-m <mongodb [ip:port,ip:port]>
|
||||
-d <mongodb database [dbname]>
|
||||
-r <redisdb [ip:port]>
|
||||
-r <redisdb [ip:port]>
|
||||
-t <redis keys ttl>
|
||||
-l <logfile>
|
||||
-T <running timeout>
|
||||
-i <influxdb [localname@ip:port]>
|
||||
-i <influxdb [localname@ip:port]>
|
||||
-C <consul [ip:port]>
|
||||
-q <parallel consumer>
|
||||
-R <retention>
|
||||
-v <version>
|
||||
|
@ -69,6 +71,7 @@ func init() {
|
|||
flag.StringVar(&dbs.Database, "d", "", "Mongodb Database")
|
||||
flag.StringVar(&dbs.RedisURI, "r", "", "Redis")
|
||||
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.BoolVar(&opts.Version, "v", false, "Version")
|
||||
flag.DurationVar(&opts.Timeout, "T", 0, "Running timeout")
|
||||
|
|
Loading…
Add table
Reference in a new issue