code: func (o *pubSubOutput) publishMessage(message *pubsub.Message) error {
  	var messageID string
  	transientErrors := 0
  	err := retry.Retry(o, transient.Only(indefiniteRetry), func() (err error) {
  		ctx := o.Context
  		if o.RPCTimeout > 0 {
  			var cancelFunc context.CancelFunc
  			ctx, cancelFunc = clock.WithTimeout(o, o.RPCTimeout)
  			defer cancelFunc()
  		}
  
  		messageID, err = o.Topic.Publish(ctx, message)
  		if err == context.DeadlineExceeded {
  			// If we hit our publish deadline, retry.
  			err = transient.Tag.Apply(err)
  		} else {
  			err = grpcutil.WrapIfTransient(err)
  		}
  		return
  	}, func(err error, d time.Duration) {
  		log.Fields{
  			log.ErrorKey: err,
  			"delay":      d,
  		}.Warningf(o, "TRANSIENT error publishing messages; retrying...")
  		transientErrors++
  	})
  	if err != nil {
  		log.WithError(err).Errorf(o, "Failed to send PubSub message.")
  		return err
  	}
  
  	if transientErrors > 0 {
  		// We successfully published, but we hit a transient error, so explicitly
  		// acknowledge this at warning-level for log message closure.
  		log.Fields{
  			"messageId":       messageID,
  			"transientErrors": transientErrors,
  		}.Warningf(o, "Successfully published messages after transient errors.")
  	} else {
  		log.Fields{
  			"messageId": messageID,
  		}.Debugf(o, "Published messages.")
  	}
  	return nil
  }
docs: // publishMessage handles an individual publish request. It will indefinitely
  // retry transient errors until the publish succeeds.