1
0
Fork 0

Export daemon String function

This commit is contained in:
Gregory Eremin 2016-01-25 01:39:38 +03:00
parent bb750bf727
commit 08db309f80
2 changed files with 6 additions and 3 deletions

View File

@ -37,6 +37,9 @@ type Daemon interface {
// close channels, process the last batch of items, etc.
Shutdown()
// String returns the name of a daemon.
String() string
// base is a (hack) function that allows the Daemon interface to reference
// underlying BaseDaemon structure.
base() *BaseDaemon

View File

@ -185,15 +185,15 @@ func (s *Shezmu) processSystemTask(t *task) {
func (s *Shezmu) processGeneralTask(t *task) {
defer func() {
if err := recover(); err != nil {
s.DaemonStats.Error(t.daemon.base().String())
s.DaemonStats.Error(t.daemon.String())
t.daemon.base().handlePanic(err)
s.Logger.Printf("Daemon %s recovered from a panic\nError: %v\n", t.daemon.base(), err)
s.Logger.Printf("Daemon %s recovered from a panic\nError: %v\n", t.daemon, err)
debug.PrintStack()
}
}()
defer func(start time.Time) {
dur := time.Now().Sub(start)
s.DaemonStats.Add(t.daemon.base().String(), dur)
s.DaemonStats.Add(t.daemon.String(), dur)
}(time.Now())
t.actor() // <--- ACTION STARTS HERE