16
16
# specific language governing permissions and limitations
17
17
# under the License.
18
18
"""This module contains a Google PubSub sensor."""
19
- import warnings
20
19
from typing import TYPE_CHECKING , Any , Callable , List , Optional , Sequence , Union
21
20
22
21
from google .cloud .pubsub_v1 .types import ReceivedMessage
@@ -49,23 +48,18 @@ class PubSubPullSensor(BaseSensorOperator):
49
48
acknowledged before being returned, otherwise, downstream tasks will be
50
49
responsible for acknowledging them.
51
50
52
- ``project`` and ``subscription`` are templated so you can use
51
+ If you want a non-blocking task that does not to wait for messages, please use
52
+ :class:`~airflow.providers.google.cloud.operators.pubsub.PubSubPullOperator`
53
+ instead.
54
+
55
+ ``project_id`` and ``subscription`` are templated so you can use
53
56
variables in them.
54
57
55
- :param project : the Google Cloud project ID for the subscription (templated)
58
+ :param project_id : the Google Cloud project ID for the subscription (templated)
56
59
:param subscription: the Pub/Sub subscription name. Do not include the
57
60
full subscription path.
58
61
:param max_messages: The maximum number of messages to retrieve per
59
62
PubSub pull request
60
- :param return_immediately:
61
- (Deprecated) This is an underlying PubSub API implementation detail.
62
- It has no real effect on Sensor behaviour other than some internal wait time before retrying
63
- on empty queue.
64
- The Sensor task will (by definition) always wait for a message, regardless of this argument value.
65
-
66
- If you want a non-blocking task that does not to wait for messages, please use
67
- :class:`~airflow.providers.google.cloud.operators.pubsub.PubSubPullOperator`
68
- instead.
69
63
:param ack_messages: If True, each message will be acknowledged
70
64
immediately rather than by any downstream tasks
71
65
:param gcp_conn_id: The connection ID to use connecting to
@@ -101,44 +95,20 @@ def __init__(
101
95
project_id : str ,
102
96
subscription : str ,
103
97
max_messages : int = 5 ,
104
- return_immediately : bool = True ,
105
98
ack_messages : bool = False ,
106
99
gcp_conn_id : str = 'google_cloud_default' ,
107
100
messages_callback : Optional [Callable [[List [ReceivedMessage ], "Context" ], Any ]] = None ,
108
101
delegate_to : Optional [str ] = None ,
109
- project : Optional [str ] = None ,
110
102
impersonation_chain : Optional [Union [str , Sequence [str ]]] = None ,
111
103
** kwargs ,
112
104
) -> None :
113
- # To preserve backward compatibility
114
- # TODO: remove one day
115
- if project :
116
- warnings .warn (
117
- "The project parameter has been deprecated. You should pass the project_id parameter." ,
118
- DeprecationWarning ,
119
- stacklevel = 2 ,
120
- )
121
- project_id = project
122
-
123
- if not return_immediately :
124
- warnings .warn (
125
- "The return_immediately parameter is deprecated.\n "
126
- " It exposes what is really just an implementation detail of underlying PubSub API.\n "
127
- " It has no effect on PubSubPullSensor behaviour.\n "
128
- " It should be left as default value of True.\n "
129
- " If is here only because of backwards compatibility.\n "
130
- " If may be removed in the future.\n " ,
131
- DeprecationWarning ,
132
- stacklevel = 2 ,
133
- )
134
105
135
106
super ().__init__ (** kwargs )
136
107
self .gcp_conn_id = gcp_conn_id
137
108
self .delegate_to = delegate_to
138
109
self .project_id = project_id
139
110
self .subscription = subscription
140
111
self .max_messages = max_messages
141
- self .return_immediately = return_immediately
142
112
self .ack_messages = ack_messages
143
113
self .messages_callback = messages_callback
144
114
self .impersonation_chain = impersonation_chain
@@ -161,7 +131,7 @@ def poke(self, context: "Context") -> bool:
161
131
project_id = self .project_id ,
162
132
subscription = self .subscription ,
163
133
max_messages = self .max_messages ,
164
- return_immediately = self . return_immediately ,
134
+ return_immediately = True ,
165
135
)
166
136
167
137
handle_messages = self .messages_callback or self ._default_message_callback
0 commit comments