Client should output one message at a time with client.Pull()

This commit is contained in:
James Mills 2018-03-25 17:11:28 -07:00
parent a67f05432d
commit ded301df46
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

View File

@ -105,20 +105,27 @@ func (c *Client) Pull(topic string) {
}
if res.StatusCode == http.StatusNotFound {
// Empty queue
break
}
defer res.Body.Close()
err = json.NewDecoder(res.Body).Decode(&msg)
if err != nil {
log.Printf(
log.Errorf(
"error decoding response from %s for %s: %s",
url, topic, err,
)
time.Sleep(c.retry)
break
} else {
c.Handle(msg)
err := c.Handle(msg)
if err != nil {
log.Errorf(
"error handling message from %s for %s: %s",
url, topic, err,
)
}
break
}
}
}