-
Notifications
You must be signed in to change notification settings - Fork 14
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
decode batch message #48
Conversation
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.
nice job, left a little comments, can you fix it?
core/msg/message.go
Outdated
|
||
func DecodeBatchMessage(msg *Message)([]*SingleMessage, error){ | ||
num := msg.Meta.GetNumMessagesInBatch() | ||
if num==0{ |
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 num==0{ | |
if num == 0 { |
core/msg/message.go
Outdated
func DecodeBatchMessage(msg *Message)([]*SingleMessage, error){ | ||
num := msg.Meta.GetNumMessagesInBatch() | ||
if num==0{ | ||
return nil,errors.New("num_message_in_batch is nil or 0") |
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.
return nil,errors.New("num_message_in_batch is nil or 0") | |
return nil, errors.New("num_message_in_batch is nil or 0") |
core/msg/message.go
Outdated
if num==0{ | ||
return nil,errors.New("num_message_in_batch is nil or 0") | ||
} | ||
return DecodeBatchPayload(msg.Payload,num) |
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.
return DecodeBatchPayload(msg.Payload,num) | |
return DecodeBatchPayload(msg.Payload, num) |
core/msg/message_test.go
Outdated
) | ||
|
||
func TestDecodeBatchPayload(t *testing.T){ | ||
payload := []byte{0,0,0,2,24,12,104,101,108,108,111,45,112,117,108,115,97,114} // hello-pulsar |
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.
payload := []byte{0,0,0,2,24,12,104,101,108,108,111,45,112,117,108,115,97,114} // hello-pulsar | |
payload := []byte{0, 0, 0, 2, 24, 12, 104, 101, 108, 108, 111, 45, 112, 117, 108, 115, 97, 114} // hello-pulsar |
core/msg/message_test.go
Outdated
func TestDecodeBatchPayload(t *testing.T){ | ||
payload := []byte{0,0,0,2,24,12,104,101,108,108,111,45,112,117,108,115,97,114} // hello-pulsar | ||
list,err := DecodeBatchPayload(payload,1) | ||
if err!=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.
if err!=nil{ | |
if err != nil { |
core/msg/message_test.go
Outdated
if err!=nil{ | ||
t.Fatal(err) | ||
} | ||
if get,want := len(list),1;get!=want{ |
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 get,want := len(list),1;get!=want{ | |
if get, want := len(list), 1; get!=want { |
core/msg/message_test.go
Outdated
t.Fatal(err) | ||
} | ||
if get,want := len(list),1;get!=want{ | ||
t.Errorf("want %v, but get %v",get,want) |
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.
t.Errorf("want %v, but get %v",get,want) | |
t.Errorf("want %v, but get %v", get, want) |
core/msg/message_test.go
Outdated
} | ||
|
||
m := list[0] | ||
if get,want := string(m.SinglePayload), "hello-pulsar";get!=want{ |
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 get,want := string(m.SinglePayload), "hello-pulsar";get!=want{ | |
if get, want := string(m.SinglePayload), "hello-pulsar"; get != want { |
core/msg/message_test.go
Outdated
|
||
m := list[0] | ||
if get,want := string(m.SinglePayload), "hello-pulsar";get!=want{ | ||
t.Errorf("want %v, but get %v",get,want) |
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.
t.Errorf("want %v, but get %v",get,want) | |
t.Errorf("want %v, but get %v",get, want) |
core/msg/message.go
Outdated
SinglePayload []byte | ||
} | ||
|
||
func DecodeBatchMessage(msg *Message)([]*SingleMessage, error){ |
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.
exported function should have comment
Sorry for so many problems of format, i have fix them. And thank you very much for pointing out every mistake. |
Provides a method for parsing the payload generated by the producer using the batch produce option.