convert error fromating to %w everywhere (#6995)
This commit is contained in:
@@ -44,13 +44,13 @@ func NewPublishSession(agentAddress string, topicSchema *schema.Schema, partitio
|
||||
|
||||
stream, err := agentClient.PublishRecord(context.Background())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("publish record: %v", err)
|
||||
return nil, fmt.Errorf("publish record: %w", err)
|
||||
}
|
||||
|
||||
if err = stream.Send(&mq_agent_pb.PublishRecordRequest{
|
||||
SessionId: resp.SessionId,
|
||||
}); err != nil {
|
||||
return nil, fmt.Errorf("send session id: %v", err)
|
||||
return nil, fmt.Errorf("send session id: %w", err)
|
||||
}
|
||||
|
||||
return &PublishSession{
|
||||
@@ -67,7 +67,7 @@ func (a *PublishSession) CloseSession() error {
|
||||
}
|
||||
err := a.stream.CloseSend()
|
||||
if err != nil {
|
||||
return fmt.Errorf("close send: %v", err)
|
||||
return fmt.Errorf("close send: %w", err)
|
||||
}
|
||||
a.schema = nil
|
||||
return err
|
||||
|
||||
@@ -50,13 +50,13 @@ func NewSubscribeSession(agentAddress string, option *SubscribeOption) (*Subscri
|
||||
|
||||
stream, err := agentClient.SubscribeRecord(context.Background())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("subscribe record: %v", err)
|
||||
return nil, fmt.Errorf("subscribe record: %w", err)
|
||||
}
|
||||
|
||||
if err = stream.Send(&mq_agent_pb.SubscribeRecordRequest{
|
||||
Init: initRequest,
|
||||
}); err != nil {
|
||||
return nil, fmt.Errorf("send session id: %v", err)
|
||||
return nil, fmt.Errorf("send session id: %w", err)
|
||||
}
|
||||
|
||||
return &SubscribeSession{
|
||||
|
||||
@@ -38,7 +38,7 @@ func (p *TopicPublisher) PublishRecord(key []byte, recordValue *schema_pb.Record
|
||||
// serialize record value
|
||||
value, err := proto.Marshal(recordValue)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal record value: %v", err)
|
||||
return fmt.Errorf("failed to marshal record value: %w", err)
|
||||
}
|
||||
|
||||
return p.doPublish(key, value)
|
||||
|
||||
@@ -137,7 +137,7 @@ func (p *TopicPublisher) doPublishToPartition(job *EachPartitionPublishJob) erro
|
||||
brokerClient := mq_pb.NewSeaweedMessagingClient(grpcConnection)
|
||||
stream, err := brokerClient.PublishMessage(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("create publish client: %v", err)
|
||||
return fmt.Errorf("create publish client: %w", err)
|
||||
}
|
||||
publishClient := &PublishClient{
|
||||
SeaweedMessaging_PublishMessageClient: stream,
|
||||
@@ -154,12 +154,12 @@ func (p *TopicPublisher) doPublishToPartition(job *EachPartitionPublishJob) erro
|
||||
},
|
||||
},
|
||||
}); err != nil {
|
||||
return fmt.Errorf("send init message: %v", err)
|
||||
return fmt.Errorf("send init message: %w", err)
|
||||
}
|
||||
// process the hello message
|
||||
resp, err := stream.Recv()
|
||||
if err != nil {
|
||||
return fmt.Errorf("recv init response: %v", err)
|
||||
return fmt.Errorf("recv init response: %w", err)
|
||||
}
|
||||
if resp.Error != "" {
|
||||
return fmt.Errorf("init response error: %v", resp.Error)
|
||||
@@ -208,7 +208,7 @@ func (p *TopicPublisher) doPublishToPartition(job *EachPartitionPublishJob) erro
|
||||
Data: data,
|
||||
},
|
||||
}); err != nil {
|
||||
return fmt.Errorf("send publish data: %v", err)
|
||||
return fmt.Errorf("send publish data: %w", err)
|
||||
}
|
||||
publishCounter++
|
||||
atomic.StoreInt64(&publishedTsNs, data.TsNs)
|
||||
@@ -218,7 +218,7 @@ func (p *TopicPublisher) doPublishToPartition(job *EachPartitionPublishJob) erro
|
||||
} else {
|
||||
// CloseSend would cancel the context on the server side
|
||||
if err := publishClient.CloseSend(); err != nil {
|
||||
return fmt.Errorf("close send: %v", err)
|
||||
return fmt.Errorf("close send: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ func (sub *TopicSubscriber) onEachPartition(assigned *mq_pb.BrokerPartitionAssig
|
||||
|
||||
subscribeClient, err := client.SubscribeMessage(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("create subscribe client: %v", err)
|
||||
return fmt.Errorf("create subscribe client: %w", err)
|
||||
}
|
||||
|
||||
slidingWindowSize := sub.SubscriberConfig.SlidingWindowSize
|
||||
@@ -94,7 +94,7 @@ func (sub *TopicSubscriber) onEachPartition(assigned *mq_pb.BrokerPartitionAssig
|
||||
if errors.Is(err, io.EOF) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("subscribe recv: %v", err)
|
||||
return fmt.Errorf("subscribe recv: %w", err)
|
||||
}
|
||||
if resp.Message == nil {
|
||||
glog.V(0).Infof("subscriber %s/%s received nil message", sub.ContentConfig.Topic, sub.SubscriberConfig.ConsumerGroup)
|
||||
|
||||
Reference in New Issue
Block a user