Skip to content

Commit

Permalink
Merge 50a6977 into 84cff04
Browse files Browse the repository at this point in the history
  • Loading branch information
andrehp committed Oct 30, 2019
2 parents 84cff04 + 50a6977 commit 3da0f5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cluster/etcd_service_discovery.go
Expand Up @@ -48,6 +48,8 @@ type etcdServiceDiscovery struct {
serverMapByType map[string]map[string]*Server
serverMapByID sync.Map
etcdEndpoints []string
etcdUser string
etcdPass string
etcdPrefix string
etcdDialTimeout time.Duration
running bool
Expand Down Expand Up @@ -94,6 +96,8 @@ func NewEtcdServiceDiscovery(

func (sd *etcdServiceDiscovery) configure() {
sd.etcdEndpoints = sd.config.GetStringSlice("pitaya.cluster.sd.etcd.endpoints")
sd.etcdUser = sd.config.GetString("pitaya.cluster.sd.etcd.user")
sd.etcdPass = sd.config.GetString("pitaya.cluster.sd.etcd.pass")
sd.etcdDialTimeout = sd.config.GetDuration("pitaya.cluster.sd.etcd.dialtimeout")
sd.etcdPrefix = sd.config.GetString("pitaya.cluster.sd.etcd.prefix")
sd.heartbeatTTL = sd.config.GetDuration("pitaya.cluster.sd.etcd.heartbeat.ttl")
Expand Down Expand Up @@ -330,10 +334,15 @@ func (sd *etcdServiceDiscovery) Init() error {
var cli *clientv3.Client
var err error
if sd.cli == nil {
cli, err = clientv3.New(clientv3.Config{
config := clientv3.Config{
Endpoints: sd.etcdEndpoints,
DialTimeout: sd.etcdDialTimeout,
})
}
if sd.etcdUser != "" && sd.etcdPass != "" {
config.Username = sd.etcdUser
config.Password = sd.etcdPass
}
cli, err = clientv3.New(config)
if err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions docs/configuration.rst
Expand Up @@ -27,6 +27,14 @@ These configuration values configure service discovery for the default etcd serv
- localhost:2379
- string
- List of comma separated etcd endpoints
* - pitaya.cluster.sd.etcd.user
-
- string
- Username to connect to etcd
* - pitaya.cluster.sd.etcd.pass
-
- string
- Password to connect to etcd
* - pitaya.cluster.sd.etcd.heartbeat.ttl
- 60s
- time.Time
Expand Down

0 comments on commit 3da0f5a

Please sign in to comment.