wenfengwang commented on a change in pull request #103: [ISSUE #93] More
usability API
URL: https://github.com/apache/rocketmq-client-go/pull/103#discussion_r301387048
##########
File path: producer/producer.go
##########
@@ -178,41 +168,42 @@ func (p *defaultProducer) sendSync(ctx context.Context,
msg *primitive.Message,
return err
}
-func (p *defaultProducer) SendAsync(ctx context.Context, msg
*primitive.Message, h func(context.Context, *primitive.SendResult, error))
error {
+func (p *defaultProducer) SendAsync(ctx context.Context, f
func(context.Context, *primitive.SendResult), msg *primitive.Message) error {
if err := p.checkMsg(msg); err != nil {
return err
}
if p.interceptor != nil {
- primitive.WithMehod(ctx, primitive.SendAsync)
+ primitive.WithMethod(ctx, primitive.SendAsync)
return p.interceptor(ctx, msg, nil, func(ctx context.Context,
req, reply interface{}) error {
- return p.sendAsync(ctx, msg, h)
+ return p.sendAsync(ctx, msg, f)
})
}
- return p.sendAsync(ctx, msg, h)
+ return p.sendAsync(ctx, msg, f)
}
-func (p *defaultProducer) sendAsync(ctx context.Context, msg
*primitive.Message, h func(context.Context, *primitive.SendResult, error))
error {
+func (p *defaultProducer) sendAsync(ctx context.Context, msg
*primitive.Message, h func(context.Context, *primitive.SendResult)) error {
mq := p.selectMessageQueue(msg.Topic)
if mq == nil {
return errors.Errorf("the topic=%s route info not found",
msg.Topic)
}
- addr := kernel.FindBrokerAddrByName(mq.BrokerName)
+ addr := internal.FindBrokerAddrByName(mq.BrokerName)
if addr == "" {
return errors.Errorf("topic=%s route info not found", mq.Topic)
}
return p.client.InvokeAsync(addr, p.buildSendRequest(mq, msg),
3*time.Second, func(command *remote.RemotingCommand, e error) {
+ resp := new(primitive.SendResult)
if e != nil {
- h(ctx, nil, e)
- return
+ resp.Error = e
+ h(ctx, nil)
Review comment:
the line was deleted
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services