Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding etcd auth #118

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cluster/etcd_service_discovery.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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