Lee-W commented on code in PR #42080:
URL: https://github.com/apache/airflow/pull/42080#discussion_r1770768834
##########
airflow/providers/google/cloud/sensors/pubsub.py:
##########
@@ -170,22 +171,41 @@ def execute(self, context: Context) -> None:
subscription=self.subscription,
max_messages=self.max_messages,
ack_messages=self.ack_messages,
- messages_callback=self.messages_callback,
poke_interval=self.poke_interval,
gcp_conn_id=self.gcp_conn_id,
impersonation_chain=self.impersonation_chain,
),
method_name="execute_complete",
)
- def execute_complete(self, context: dict[str, Any], event: dict[str, str |
list[str]]) -> str | list[str]:
+ def execute_complete(self, context: Context, event: dict[str, str |
list[str]]) -> Any:
"""Return immediately and relies on trigger to throw a success event.
Callback for the trigger."""
if event["status"] == "success":
self.log.info("Sensor pulls messages: %s", event["message"])
+ if self.messages_callback:
+ received_message_fmt =
self._convert_to_received_message(event["message"])
Review Comment:
I got the idea here. let me add a new suggestion
##########
airflow/providers/google/cloud/sensors/pubsub.py:
##########
@@ -170,22 +171,41 @@ def execute(self, context: Context) -> None:
subscription=self.subscription,
max_messages=self.max_messages,
ack_messages=self.ack_messages,
- messages_callback=self.messages_callback,
poke_interval=self.poke_interval,
gcp_conn_id=self.gcp_conn_id,
impersonation_chain=self.impersonation_chain,
),
method_name="execute_complete",
)
- def execute_complete(self, context: dict[str, Any], event: dict[str, str |
list[str]]) -> str | list[str]:
+ def execute_complete(self, context: Context, event: dict[str, str |
list[str]]) -> Any:
Review Comment:
ah, I got it. yep Any is right.
##########
airflow/providers/google/cloud/sensors/pubsub.py:
##########
@@ -170,22 +171,36 @@ def execute(self, context: Context) -> None:
subscription=self.subscription,
max_messages=self.max_messages,
ack_messages=self.ack_messages,
- messages_callback=self.messages_callback,
poke_interval=self.poke_interval,
gcp_conn_id=self.gcp_conn_id,
impersonation_chain=self.impersonation_chain,
),
method_name="execute_complete",
)
- def execute_complete(self, context: dict[str, Any], event: dict[str, str |
list[str]]) -> str | list[str]:
- """Return immediately and relies on trigger to throw a success event.
Callback for the trigger."""
+ def execute_complete(self, context: Context, event: dict[str, str |
list[str]]) -> Any:
+ """If messages_callback is provided, execute it; otherwise, return
immediately with trigger event message."""
if event["status"] == "success":
self.log.info("Sensor pulls messages: %s", event["message"])
+ if self.messages_callback:
Review Comment:
Do we need to run `self._default_message_callback` here?
--
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]