Skip to content

Commit

Permalink
log heartbeat if true on config
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod authored and felipejfc committed May 12, 2018
1 parent e77f87c commit 835b28e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cluster/etcd_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type etcdServiceDiscovery struct {
heartbeatInterval time.Duration
syncServersInterval time.Duration
heartbeatTTL time.Duration
heartbeatLog bool
leaseID clientv3.LeaseID
serverMapByType sync.Map
serverMapByID sync.Map
Expand Down Expand Up @@ -84,6 +85,7 @@ func (sd *etcdServiceDiscovery) configure() {
sd.etcdPrefix = sd.config.GetString("pitaya.cluster.sd.etcd.prefix")
sd.heartbeatInterval = sd.config.GetDuration("pitaya.cluster.sd.etcd.heartbeat.interval")
sd.heartbeatTTL = sd.config.GetDuration("pitaya.cluster.sd.etcd.heartbeat.ttl")
sd.heartbeatLog = sd.config.GetBool("pitaya.cluster.sd.etcd.heartbeat.log")
sd.syncServersInterval = sd.config.GetDuration("pitaya.cluster.sd.etcd.syncservers.interval")
}

Expand Down Expand Up @@ -253,7 +255,9 @@ func (sd *etcdServiceDiscovery) Init() error {

// Heartbeat sends a heartbeat to etcd
func (sd *etcdServiceDiscovery) Heartbeat() error {
logger.Log.Debugf("renewing heartbeat with lease %s", sd.leaseID)
if sd.heartbeatLog {
logger.Log.Debugf("renewing heartbeat with lease %s", sd.leaseID)
}
_, err := sd.cli.KeepAliveOnce(context.TODO(), sd.leaseID)
if err != nil {
return err
Expand Down

0 comments on commit 835b28e

Please sign in to comment.