@@ -16,12 +16,21 @@ import (
16
16
"github.com/micro/go-micro/registry"
17
17
"github.com/signal18/replication-manager/config"
18
18
"github.com/signal18/replication-manager/utils/misc"
19
+ "github.com/spf13/pflag"
19
20
)
20
21
21
22
type ConsulProxy struct {
22
23
Proxy
23
24
}
24
25
26
+ func (proxy * ConsulProxy ) AddFlags (flags * pflag.FlagSet , conf * config.Config ) {
27
+ flags .BoolVar (& conf .RegistryConsul , "registry-consul" , false , "Register write and read SRV DNS to consul" )
28
+ flags .StringVar (& conf .RegistryConsulCredential , "registry-consul-credential" , ":" , "Consul credential user:password" )
29
+ flags .StringVar (& conf .RegistryConsulToken , "registry-consul-token" , "" , "Consul Token" )
30
+ flags .StringVar (& conf .RegistryConsulHosts , "registry-servers" , "127.0.0.1" , "Comma-separated list of registry addresses" )
31
+ flags .StringVar (& conf .RegistryConsulJanitorWeights , "registry-consul-weights" , "100" , "Weight of each proxysql host inside janitor proxy" )
32
+ }
33
+
25
34
func NewConsulProxy (placement int , cluster * Cluster , proxyHost string ) * ConsulProxy {
26
35
conf := cluster .Conf
27
36
prx := new (ConsulProxy )
@@ -36,7 +45,7 @@ func NewConsulProxy(placement int, cluster *Cluster, proxyHost string) *ConsulPr
36
45
prx .WritePort , _ = strconv .Atoi (conf .ProxysqlPort )
37
46
prx .ReadPort , _ = strconv .Atoi (conf .ProxysqlPort )
38
47
39
- prx .SetPlacement (placement , conf .ProvProxAgents , conf .SlapOSProxySQLPartitions , conf .ProxysqlHostsIPV6 )
48
+ prx .SetPlacement (placement , conf .ProvProxAgents , conf .SlapOSProxySQLPartitions , conf .ProxysqlHostsIPV6 , conf . RegistryConsulJanitorWeights )
40
49
41
50
if conf .ProvNetCNI {
42
51
if conf .ClusterHead == "" {
@@ -58,7 +67,7 @@ func (proxy *ConsulProxy) Init() {
58
67
if cluster .Conf .RegistryConsul == false || cluster .IsActive () == false {
59
68
return
60
69
}
61
- opt .Addrs = strings .Split (cluster .Conf .RegistryHosts , "," )
70
+ opt .Addrs = strings .Split (cluster .Conf .RegistryConsulHosts , "," )
62
71
//DefaultRegistry()
63
72
//opt := registry.DefaultRegistry
64
73
reg := registry .NewRegistry ()
0 commit comments