1
0
mirror of https://github.com/containous/traefik.git synced 2024-12-22 13:34:03 +03:00

remove confusing go-marathon log message

Log message produced by go-marathon was:
time="2017-06-28T09:08:19Z" level=debug msg="listenToSSE(): failed to
handle event: failed to decode the event type, content: , error: EOF"

The fix for this was done in the upstream project of go-marathon
donovanhide/eventsource.

Background is that Marathon periodically sends a \n over the SSE
subscription, in order to keep the connection alive. This was parsed as
empty event by the eventsource and published. go-marathon in turn was
not able to do something with this empty event was producing the log
message above. By getting rid of publishing empty events in the
downstream library, we also get rid of this log message.
This commit is contained in:
Marco Jantke 2017-06-30 11:06:14 +02:00 committed by Ludovic Fernandez
parent 81d011e57d
commit 2c976227dd
2 changed files with 9 additions and 4 deletions

4
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: 4e2a6a4fe84b2843ff946fe56deae17f8c7666e2e6567d8a75f4b0bdd7cb0280
updated: 2017-06-29T16:47:14.848940186+02:00
updated: 2017-06-30T11:03:09.025639582+02:00
imports:
- name: cloud.google.com/go
version: 2e6a95edb1071d750f6d7db777bf66cd2997af6c
@ -172,7 +172,7 @@ imports:
- store/etcd
- store/zookeeper
- name: github.com/donovanhide/eventsource
version: 441a03aa37b3329bbb79f43de81914ea18724718
version: b8f31a59085e69dd2678cf51840db2ac625cb741
- name: github.com/eapache/channels
version: 47238d5aae8c0fefd518ef2bee46290909cf8263
- name: github.com/eapache/queue

View File

@ -35,7 +35,6 @@ func NewDecoder(r io.Reader) *Decoder {
// Any error occuring mid-event is considered non-graceful and will
// show up as some other error (most likely io.ErrUnexpectedEOF).
func (dec *Decoder) Decode() (Event, error) {
// peek ahead before we start a new event so we can return EOFs
_, err := dec.Peek(1)
if err == io.ErrUnexpectedEOF {
@ -45,13 +44,18 @@ func (dec *Decoder) Decode() (Event, error) {
return nil, err
}
pub := new(publication)
inDecoding := false
for {
line, err := dec.ReadString('\n')
if err != nil {
return nil, err
}
if line == "\n" {
if line == "\n" && inDecoding {
// the empty line signals the end of an event
break
} else if line == "\n" && !inDecoding {
// only a newline was sent, so we don't want to publish an empty event but try to read again
continue
}
line = strings.TrimSuffix(line, "\n")
if strings.HasPrefix(line, ":") {
@ -62,6 +66,7 @@ func (dec *Decoder) Decode() (Event, error) {
if len(sections) == 2 {
value = strings.TrimPrefix(sections[1], " ")
}
inDecoding = true
switch field {
case "event":
pub.event = value