LaPetiteSouris commented on code in PR #24554:
URL: https://github.com/apache/airflow/pull/24554#discussion_r902993431


##########
airflow/providers/amazon/aws/sensors/sqs.py:
##########
@@ -215,3 +229,68 @@ def __init__(self, *args, **kwargs):
             stacklevel=2,
         )
         super().__init__(*args, **kwargs)
+
+
+class SqsBatchSensor(SqsSensor):
+    """
+    Get messages from an Amazon SQS queue in batches and then delete the 
retrieved messages from the queue.
+    If deletion of messages fails an AirflowException is thrown. Otherwise, 
all messages
+    are pushed through XCom with the key ``messages``.
+
+    This sensor is identical to SqsSensor, except that SqsSensor performs one 
and only one SQS call
+    per poke, which limits the result to a maximum of 10 messages, while 
SqsBatchSensor performs multiple
+    SQS API calls per poke and combines the results into one list.
+
+    .. seealso::
+        For more information on how to use this sensor, take a look at the 
guide:
+        :ref:`howto/sensor:SqsBatchSensor`
+
+    :param num_batches: The number of times the sensor will call the SQS API 
to receive messages (default: 1)

Review Comment:
   That was my first thought. The initial version I implemented was to add 
`num_batches` and the default value is set to 1. The only reason to keep it 
separate is to make sure that the new behavior will have absolutely no impact 
whatsoever on the existing `SqsSensor`
   
   It was a deliberate action to separate the two so that the PR does have 
minimal impact on existing piece of code.
   
   However, I do agree that just teaching `SqsSensor` to do batches is really 
clean. Probably it needs a few more unit tests just to make sure.
   
   Shall we drop `SqsBatchSensor` and add `num_batches` in normal `SqsSensor`  
and add a bunch of extra unit tests on top ?



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to