TobKed commented on a change in pull request #6096: [AIRFLOW-5477] Rewrite 
Google PubSub Hook to Google Cloud Python
URL: https://github.com/apache/airflow/pull/6096#discussion_r324696962
 
 

 ##########
 File path: airflow/gcp/hooks/pubsub.py
 ##########
 @@ -292,14 +504,38 @@ def acknowledge(self, project: str, subscription: str, 
ack_ids: List) -> None:
         :param ack_ids: List of ReceivedMessage ackIds from a previous pull
             response
         :type ack_ids: list
+        :param retry: (Optional) A retry object used to retry requests.
+            If None is specified, requests will not be retried.
+        :type retry: google.api_core.retry.Retry
+        :param timeout: (Optional) The amount of time, in seconds, to wait for 
the request
+            to complete. Note that if retry is specified, the timeout applies 
to each
+            individual attempt.
+        :type timeout: float
+        :param metadata: (Optional) Additional metadata that is provided to 
the method.
+        :type metadata: Sequence[Tuple[str, str]]]
         """
-        service = self.get_conn()
-        full_subscription = _format_subscription(project, subscription)
+        subscriber = self.subscriber_client
+        subscription_path = SubscriberClient.subscription_path(project, 
subscription)  # noqa E501 # pylint: disable=no-member,line-too-long
+
+        self.log.info("Acknowledging %d ack_ids from subscription (path) %s", 
len(ack_ids), subscription_path)
         try:
-            service.projects().subscriptions().acknowledge(  # pylint: 
disable=no-member
-                subscription=full_subscription, body={'ackIds': ack_ids}
-            ).execute(num_retries=self.num_retries)
+            # pylint: disable=no-member
+            subscriber.acknowledge(
+                subscription=subscription_path,
+                ack_ids=ack_ids,
+                retry=retry,
+                timeout=timeout,
+                metadata=metadata,
+            )
         except HttpError as e:
             raise PubSubException(
                 'Error acknowledging {} messages pulled from subscription {}'
-                .format(len(ack_ids), full_subscription), e)
+                .format(len(ack_ids), subscription_path), e)
+        except GoogleAPICallError as e:
+            raise PubSubException(
 
 Review comment:
   I've added test.

----------------------------------------------------------------
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

Reply via email to