Capture EOF and add option for retry interval

This commit is contained in:
Blerim Sheqa 2016-12-30 13:36:55 +01:00
parent 7bf6c0d2cf
commit f33c3da190

View File

@ -37,7 +37,7 @@ func NewEventstream(bt *Icingabeat, cfg config.Config) *Eventstream {
func (es *Eventstream) Run() error { func (es *Eventstream) Run() error {
for { for {
ticker := time.NewTicker(2 * time.Second) ticker := time.NewTicker(es.config.RetryInterval)
response, responseErr := requestURL(es.icingabeat, "POST", "/v1/events?queue=icingabeat&types=CheckResult") response, responseErr := requestURL(es.icingabeat, "POST", "/v1/events?queue=icingabeat&types=CheckResult")
if responseErr == nil { if responseErr == nil {
@ -54,7 +54,7 @@ func (es *Eventstream) Run() error {
tst := es.closer == nil tst := es.closer == nil
es.mutex.Unlock() es.mutex.Unlock()
if tst { if tst || err == io.ErrUnexpectedEOF || err == io.EOF {
break break
} }
logp.Err("Error reading line %#v", err) logp.Err("Error reading line %#v", err)
@ -68,7 +68,7 @@ func (es *Eventstream) Run() error {
tst := es.closer == nil tst := es.closer == nil
es.mutex.Unlock() es.mutex.Unlock()
if tst { if tst || err == io.ErrUnexpectedEOF || err == io.EOF {
break break
} }
continue continue
@ -86,7 +86,7 @@ func (es *Eventstream) Run() error {
default: default:
} }
} else { } else {
logp.Info("Error connecting to API:", responseErr) logp.Info("Error connecting to API: %v", responseErr)
} }
select { select {