Skip to content

Commit

Permalink
chore(pubsub): enable Go 1.13 error wrapping (+ pubsublite) (#6793)
Browse files Browse the repository at this point in the history
  • Loading branch information
quartzmo committed Oct 3, 2022
1 parent 36a45df commit 4c32b13
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions pubsub/pubsub.go
Expand Up @@ -126,7 +126,7 @@ func NewClientWithConfig(ctx context.Context, projectID string, config *ClientCo
if addr := os.Getenv("PUBSUB_EMULATOR_HOST"); addr != "" {
conn, err := grpc.Dial(addr, grpc.WithInsecure())
if err != nil {
return nil, fmt.Errorf("grpc.Dial: %v", err)
return nil, fmt.Errorf("grpc.Dial: %w", err)
}
o = []option.ClientOption{option.WithGRPCConn(conn)}
o = append(o, option.WithTelemetryDisabled())
Expand All @@ -146,11 +146,11 @@ func NewClientWithConfig(ctx context.Context, projectID string, config *ClientCo
o = append(o, opts...)
pubc, err := vkit.NewPublisherClient(ctx, o...)
if err != nil {
return nil, fmt.Errorf("pubsub(publisher): %v", err)
return nil, fmt.Errorf("pubsub(publisher): %w", err)
}
subc, err := vkit.NewSubscriberClient(ctx, o...)
if err != nil {
return nil, fmt.Errorf("pubsub(subscriber): %v", err)
return nil, fmt.Errorf("pubsub(subscriber): %w", err)
}
if config != nil {
pubc.CallOptions = mergePublisherCallOptions(pubc.CallOptions, config.PublisherCallOptions)
Expand All @@ -173,7 +173,7 @@ func (c *Client) Close() error {
pubErr := c.pubc.Close()
subErr := c.subc.Close()
if pubErr != nil {
return fmt.Errorf("pubsub publisher closing error: %v", pubErr)
return fmt.Errorf("pubsub publisher closing error: %w", pubErr)
}
if subErr != nil {
// Suppress client connection closing errors. This will only happen
Expand All @@ -183,7 +183,7 @@ func (c *Client) Close() error {
if strings.Contains(subErr.Error(), "the client connection is closing") {
return nil
}
return fmt.Errorf("pubsub subscriber closing error: %v", subErr)
return fmt.Errorf("pubsub subscriber closing error: %w", subErr)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pubsub/subscription.go
Expand Up @@ -828,7 +828,7 @@ type SubscriptionConfigToUpdate struct {
func (s *Subscription) Update(ctx context.Context, cfg SubscriptionConfigToUpdate) (SubscriptionConfig, error) {
req := s.updateRequest(&cfg)
if err := cfg.validate(); err != nil {
return SubscriptionConfig{}, fmt.Errorf("pubsub: UpdateSubscription %v", err)
return SubscriptionConfig{}, fmt.Errorf("pubsub: UpdateSubscription %w", err)
}
if len(req.UpdateMask.Paths) == 0 {
return SubscriptionConfig{}, errors.New("pubsub: UpdateSubscription call with nothing to update")
Expand Down
2 changes: 1 addition & 1 deletion pubsublite/config.go
Expand Up @@ -119,7 +119,7 @@ func protoToTopicConfig(t *pb.Topic) (*TopicConfig, error) {
if retentionCfg.Period != nil {
period, err := ptypes.Duration(retentionCfg.Period)
if err != nil {
return nil, fmt.Errorf("pubsublite: invalid retention period in topic config: %v", err)
return nil, fmt.Errorf("pubsublite: invalid retention period in topic config: %w", err)
}
topic.RetentionDuration = period
}
Expand Down
2 changes: 1 addition & 1 deletion pubsublite/internal/wire/assigner.go
Expand Up @@ -97,7 +97,7 @@ type assigner struct {
func newAssigner(ctx context.Context, assignmentClient *vkit.PartitionAssignmentClient, genUUID generateUUIDFunc, settings ReceiveSettings, subscriptionPath string, receiver partitionAssignmentReceiver) (*assigner, error) {
clientID, err := genUUID()
if err != nil {
return nil, fmt.Errorf("pubsublite: failed to generate client UUID: %v", err)
return nil, fmt.Errorf("pubsublite: failed to generate client UUID: %w", err)
}

a := &assigner{
Expand Down
2 changes: 1 addition & 1 deletion pubsublite/internal/wire/publish_batcher.go
Expand Up @@ -123,7 +123,7 @@ func (b *publishMessageBatcher) AddMessage(msg *pb.PubSubMessage, onResult Publi
if err := b.msgBundler.Add(holder, msgSize); err != nil {
// As we've already checked the size of the message and overflow, the
// bundler should not return an error.
return fmt.Errorf("pubsublite: failed to batch message: %v", err)
return fmt.Errorf("pubsublite: failed to batch message: %w", err)
}
b.availableBufferBytes -= msgSize
return nil
Expand Down

0 comments on commit 4c32b13

Please sign in to comment.