def _default_message_callback( self, pulled_messages: List[ReceivedMessage], context: "Context", ) -> list: """ This method can be overridden by subclasses or by `messages_callback` constructor argument. This default implementation converts `ReceivedMessage` objects into JSON-serializable dicts. :param pulled_messages: messages received from the topic. :param context: same as in `execute` :return: value to be saved to XCom. """ messages_json = [ReceivedMessage.to_dict(m) for m in pulled_messages] return messages_json
def _generate_dicts(self, count): return [ ReceivedMessage.to_dict(m) for m in self._generate_messages(count) ]