From 2c976227dddb7bc180ff79881cde7a3adb256b0c Mon Sep 17 00:00:00 2001 From: Marco Jantke Date: Fri, 30 Jun 2017 11:06:14 +0200 Subject: [PATCH] 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. --- glide.lock | 4 ++-- vendor/github.com/donovanhide/eventsource/decoder.go | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/glide.lock b/glide.lock index 68f6cb42b..d9749e3fe 100644 --- a/glide.lock +++ b/glide.lock @@ -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 diff --git a/vendor/github.com/donovanhide/eventsource/decoder.go b/vendor/github.com/donovanhide/eventsource/decoder.go index 1db90e7c7..df339b25e 100644 --- a/vendor/github.com/donovanhide/eventsource/decoder.go +++ b/vendor/github.com/donovanhide/eventsource/decoder.go @@ -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