Skip to content

Commit

Permalink
Add debug and erro logs in WithRedisLock watcher method
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiz Felipe Takakura committed Dec 13, 2018
1 parent 613ecf8 commit d6462f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ _testmain.go

# IDE files
.vscode
.history

# Python
__pycache__
Expand Down
14 changes: 13 additions & 1 deletion watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,23 @@ func (w *Watcher) WithRedisLock(l *logrus.Entry, f func() error) {
l.Warnf("unable to get watcher %s lock, maybe some other process has it...", w.SchedulerName)
}
} else if lock.IsLocked() {
l.WithFields(logrus.Fields{
"lockKey": w.LockKey,
"scheduler": w.SchedulerName,
}).Debug("lock acquired")
err = f()
if err != nil {
l.WithError(err).Error("WithRedisLock block function failed")
}
w.RedisClient.LeaveCriticalSection(lock)
err = w.RedisClient.LeaveCriticalSection(lock)
if err != nil {
l.WithError(err).Error("LeaveCriticalSection failed to release lock")
} else {
l.WithFields(logrus.Fields{
"lockKey": w.LockKey,
"scheduler": w.SchedulerName,
}).Debug("lock released")
}
}
}

Expand Down

0 comments on commit d6462f3

Please sign in to comment.