-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send empty struct to pubsub cmd output to flush #3416
Conversation
n := binary.PutUvarint(buf, uint64(len(m.Data))) | ||
return io.MultiReader(bytes.NewReader(buf[:n]), bytes.NewReader(m.Data)), nil | ||
var ( | ||
n int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike this syntax, lets just instantiate things where they are used.
Also, no need for the m.Message != nil
check, its functionally equivalent to just saying data := m.Message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is that data
is nil if m.Message
is nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap, i know
@@ -118,16 +122,33 @@ To use, the daemon must be run with '--enable-pubsub-experiment'. | |||
}, | |||
Marshalers: cmds.MarshalerMap{ | |||
cmds.Text: getPsMsgMarshaler(func(m *floodsub.Message) (io.Reader, error) { | |||
if m.Message == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave this out too, passing a nil
byte array to a bytes.NewReader
will result in the same as passing the empty string to a stringsreader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I can't. We use m.Data
later, which is m.Message.Data
, which is a nil dereference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If m.Message
is nil, what is the value of m.Data
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Message
is embedded and Data
is part of Message
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and if m.Message
is nil, m.Message.Data
panics - so does m.Data
return bytes.NewReader(m.Data), nil | ||
}), | ||
"ndpayload": getPsMsgMarshaler(func(m *floodsub.Message) (io.Reader, error) { | ||
if m.Message == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, append([]byte(nil), '\n')
works just fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And where would I store that? m.Data
does not exist because it is actually m.Message.Data
, and m.Message
is nil
. Panic!
Oh and |
So the HTTP headers get sent License: MIT Signed-off-by: Jan Winkelmann <j-winkelmann@tuhh.de>
47cb7d1
to
7ad2f52
Compare
@keks sorry about that, I missed the fact that there was an embedded struct involved. |
I endorse this PR and/or service. Would be awesome to get this into 0.4.5-rc1 build. |
@whyrusleeping can you merge? I'll look at sharness tests next week. |
So the HTTP headers get sent