convert error fromating to %w everywhere (#6995)
This commit is contained in:
@@ -25,7 +25,7 @@ func (b *MessageQueueBroker) BrokerConnectToBalancer(brokerBalancer string, stop
|
||||
return pb.WithBrokerGrpcClient(true, brokerBalancer, b.grpcDialOption, func(client mq_pb.SeaweedMessagingClient) error {
|
||||
stream, err := client.PublisherToPubBalancer(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("connect to balancer %v: %v", brokerBalancer, err)
|
||||
return fmt.Errorf("connect to balancer %v: %w", brokerBalancer, err)
|
||||
}
|
||||
defer stream.CloseSend()
|
||||
err = stream.Send(&mq_pb.PublisherToPubBalancerRequest{
|
||||
@@ -36,7 +36,7 @@ func (b *MessageQueueBroker) BrokerConnectToBalancer(brokerBalancer string, stop
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("send init message: %v", err)
|
||||
return fmt.Errorf("send init message: %w", err)
|
||||
}
|
||||
|
||||
for {
|
||||
|
||||
@@ -66,7 +66,7 @@ func (b *MessageQueueBroker) ConfigureTopic(ctx context.Context, request *mq_pb.
|
||||
|
||||
// save the topic configuration on filer
|
||||
if err := b.fca.SaveTopicConfToFiler(t, resp); err != nil {
|
||||
return nil, fmt.Errorf("configure topic: %v", err)
|
||||
return nil, fmt.Errorf("configure topic: %w", err)
|
||||
}
|
||||
|
||||
b.PubBalancer.OnPartitionChange(request.Topic, resp.BrokerPartitionAssignments)
|
||||
|
||||
@@ -164,14 +164,14 @@ func (b *MessageQueueBroker) GetTopicConfiguration(ctx context.Context, request
|
||||
|
||||
if conf, createdAtNs, modifiedAtNs, err = b.fca.ReadTopicConfFromFilerWithMetadata(t); err != nil {
|
||||
glog.V(0).Infof("get topic configuration %s: %v", request.Topic, err)
|
||||
return nil, fmt.Errorf("failed to read topic configuration: %v", err)
|
||||
return nil, fmt.Errorf("failed to read topic configuration: %w", err)
|
||||
}
|
||||
|
||||
// Ensure topic assignments are active
|
||||
err = b.ensureTopicActiveAssignments(t, conf)
|
||||
if err != nil {
|
||||
glog.V(0).Infof("ensure topic active assignments %s: %v", request.Topic, err)
|
||||
return nil, fmt.Errorf("failed to ensure topic assignments: %v", err)
|
||||
return nil, fmt.Errorf("failed to ensure topic assignments: %w", err)
|
||||
}
|
||||
|
||||
// Build the response with complete configuration including metadata
|
||||
@@ -208,7 +208,7 @@ func (b *MessageQueueBroker) GetTopicPublishers(ctx context.Context, request *mq
|
||||
var conf *mq_pb.ConfigureTopicResponse
|
||||
if conf, _, _, err = b.fca.ReadTopicConfFromFilerWithMetadata(t); err != nil {
|
||||
glog.V(0).Infof("get topic configuration for publishers %s: %v", request.Topic, err)
|
||||
return nil, fmt.Errorf("failed to read topic configuration: %v", err)
|
||||
return nil, fmt.Errorf("failed to read topic configuration: %w", err)
|
||||
}
|
||||
|
||||
// Collect publishers from each partition that is hosted on this broker
|
||||
@@ -262,7 +262,7 @@ func (b *MessageQueueBroker) GetTopicSubscribers(ctx context.Context, request *m
|
||||
var conf *mq_pb.ConfigureTopicResponse
|
||||
if conf, _, _, err = b.fca.ReadTopicConfFromFilerWithMetadata(t); err != nil {
|
||||
glog.V(0).Infof("get topic configuration for subscribers %s: %v", request.Topic, err)
|
||||
return nil, fmt.Errorf("failed to read topic configuration: %v", err)
|
||||
return nil, fmt.Errorf("failed to read topic configuration: %w", err)
|
||||
}
|
||||
|
||||
// Collect subscribers from each partition that is hosted on this broker
|
||||
|
||||
@@ -145,7 +145,7 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis
|
||||
|
||||
// send to the local partition
|
||||
if err = localTopicPartition.Publish(dataMessage); err != nil {
|
||||
return fmt.Errorf("topic %v partition %v publish error: %v", initMessage.Topic, initMessage.Partition, err)
|
||||
return fmt.Errorf("topic %v partition %v publish error: %w", initMessage.Topic, initMessage.Partition, err)
|
||||
}
|
||||
|
||||
// Update published offset and last seen time for this publisher
|
||||
|
||||
@@ -15,7 +15,7 @@ func (b *MessageQueueBroker) PublisherToPubBalancer(stream mq_pb.SeaweedMessagin
|
||||
}
|
||||
req, err := stream.Recv()
|
||||
if err != nil {
|
||||
return fmt.Errorf("receive init message: %v", err)
|
||||
return fmt.Errorf("receive init message: %w", err)
|
||||
}
|
||||
|
||||
// process init message
|
||||
|
||||
@@ -14,12 +14,12 @@ func (b *MessageQueueBroker) GetOrGenerateLocalPartition(t topic.Topic, partitio
|
||||
conf, readConfErr := b.fca.ReadTopicConfFromFiler(t)
|
||||
if readConfErr != nil {
|
||||
glog.Errorf("topic %v not found: %v", t, readConfErr)
|
||||
return nil, fmt.Errorf("topic %v not found: %v", t, readConfErr)
|
||||
return nil, fmt.Errorf("topic %v not found: %w", t, readConfErr)
|
||||
}
|
||||
localTopicPartition, _, getOrGenError = b.doGetOrGenLocalPartition(t, partition, conf)
|
||||
if getOrGenError != nil {
|
||||
glog.Errorf("topic %v partition %v not setup: %v", t, partition, getOrGenError)
|
||||
return nil, fmt.Errorf("topic %v partition %v not setup: %v", t, partition, getOrGenError)
|
||||
return nil, fmt.Errorf("topic %v partition %v not setup: %w", t, partition, getOrGenError)
|
||||
}
|
||||
return localTopicPartition, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user