Skip to content
Permalink
Browse files

Merge pull request #234 from tufanbarisyildirim/issue/118

remove .Online from notifiers and toggle service.Online when needed. …
  • Loading branch information...
hunterlong committed Aug 27, 2019
2 parents 85b4129 + 30a1216 commit ce90d9d341a943dc5daa77fd9b9efa7584784f8f
@@ -243,7 +243,6 @@ func (s *Service) checkHttp(record bool) *Service {
}
return s
}
s.Online = true
if record {
recordSuccess(s)
}
@@ -252,7 +251,6 @@ func (s *Service) checkHttp(record bool) *Service {

// recordSuccess will create a new 'hit' record in the database for a successful/online service
func recordSuccess(s *Service) {
s.Online = true
s.LastOnline = utils.Timezoner(time.Now().UTC(), CoreApp.Timezone)
hit := &types.Hit{
Service: s.Id,
@@ -263,11 +261,11 @@ func recordSuccess(s *Service) {
utils.Log(1, fmt.Sprintf("Service %v Successful Response: %0.2f ms | Lookup in: %0.2f ms", s.Name, hit.Latency*1000, hit.PingTime*1000))
s.CreateHit(hit)
notifier.OnSuccess(s.Service)
s.Online = true
}

// recordFailure will create a new 'Failure' record in the database for a offline service
func recordFailure(s *Service, issue string) {
s.Online = false
fail := &Failure{&types.Failure{
Service: s.Id,
Issue: issue,
@@ -278,4 +276,6 @@ func recordFailure(s *Service, issue string) {
utils.Log(2, fmt.Sprintf("Service %v Failing: %v | Lookup in: %0.2f ms", s.Name, issue, fail.PingTime*1000))
s.CreateFailure(fail)
notifier.OnFailure(s.Service, fail.Failure)
s.Online = false

}
@@ -39,6 +39,7 @@ func OnFailure(s *types.Service, f *types.Failure) {
comm.(BasicEvents).OnFailure(s, f)
}
}

}

// OnSuccess will be triggered when a service is successful - BasicEvents interface
@@ -51,6 +52,7 @@ func OnSuccess(s *types.Service) {
comm.(BasicEvents).OnSuccess(s)
}
}

}

// OnNewService is triggered when a new service is created - ServiceEvents interface
@@ -62,7 +62,6 @@ type Notification struct {
Delay time.Duration `gorm:"-" json:"delay,string"`
Queue []*QueueData `gorm:"-" json:"-"`
Running chan bool `gorm:"-" json:"-"`
Online bool `gorm:"-" json:"online"`
testable bool `gorm:"-" json:"testable"`
}

0 comments on commit ce90d9d

Please sign in to comment.
You can’t perform that action at this time.