def _generate_messages(self, count): return [ ReceivedMessage( ack_id=f"{i}", message={ "data": f'Message {i}'.encode('utf8'), "attributes": {"type": "generated message"}, }, ) for i in range(1, count + 1) ]
def _generate_messages(self, count): return [ ParseDict( { "ack_id": "%s" % i, "message": { "data": 'Message {}'.format(i).encode('utf8'), "attributes": {"type": "generated message"}, }, }, ReceivedMessage(), ) for i in range(1, count + 1) ]
def _generate_messages(self, count) -> List[ReceivedMessage]: return [ ParseDict( { "ack_id": str(i), "message": { "data": f'Message {i}'.encode('utf8'), "attributes": {"type": "generated message"}, }, }, ReceivedMessage(), ) for i in range(1, count + 1) ]
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) ]