Ejemplo n.º 1
0
    def consumer_instance(self, consumer_group_name, force_payload_decode,
                          topic, team_name, pre_rebalance_callback,
                          post_rebalance_callback, registered_schema,
                          registered_compatible_schema,
                          registered_non_compatible_schema):
        consumer_source = FixedSchemas(
            registered_schema.schema_id,
            registered_non_compatible_schema.schema_id)

        consumer = Consumer(
            consumer_name=consumer_group_name,
            team_name=team_name,
            expected_frequency_seconds=ExpectedFrequency.constantly,
            topic_to_consumer_topic_state_map=None,
            consumer_source=consumer_source,
            force_payload_decode=force_payload_decode,
            auto_offset_reset='largest',  # start from the tail of the topic
            pre_rebalance_callback=pre_rebalance_callback,
            post_rebalance_callback=post_rebalance_callback,
        )
        with mock.patch.object(
                consumer,
                '_get_topics_in_region_from_topic_name',
                side_effect=[[x] for x in consumer_source.get_topics()]):
            yield consumer
Ejemplo n.º 2
0
    def consumer_instance(
        self,
        consumer_group_name,
        force_payload_decode,
        topic,
        team_name,
        pre_rebalance_callback,
        post_rebalance_callback,
        registered_schema,
        registered_compatible_schema,
        registered_non_compatible_schema
    ):
        consumer_source = FixedSchemas(
            registered_schema.schema_id,
            registered_non_compatible_schema.schema_id
        )

        consumer = Consumer(
            consumer_name=consumer_group_name,
            team_name=team_name,
            expected_frequency_seconds=ExpectedFrequency.constantly,
            topic_to_consumer_topic_state_map=None,
            consumer_source=consumer_source,
            force_payload_decode=force_payload_decode,
            auto_offset_reset='largest',  # start from the tail of the topic
            pre_rebalance_callback=pre_rebalance_callback,
            post_rebalance_callback=post_rebalance_callback,
        )
        with mock.patch.object(
            consumer,
            '_get_topics_in_region_from_topic_name',
            side_effect=[[x] for x in consumer_source.get_topics()]
        ):
            yield consumer
Ejemplo n.º 3
0
 def test_invalid_schema(self):
     with pytest.raises(ValueError):
         FixedSchemas()
     with pytest.raises(ValueError):
         FixedSchemas(0)
     with pytest.raises(ValueError):
         FixedSchemas('')
     with pytest.raises(ValueError):
         FixedSchemas('', '')
Ejemplo n.º 4
0
 def bad_consumer_source(self, schema_with_bad_topic):
     return FixedSchemas(schema_with_bad_topic.schema_id)
Ejemplo n.º 5
0
 def consumer_source(self, foo_schema, foo_schema2):
     return FixedSchemas(
         foo_schema.schema_id,
         foo_schema2.schema_id,
     )
Ejemplo n.º 6
0
 def consumer_source(self, foo_schema, bar_schema):
     return FixedSchemas(foo_schema.schema_id, bar_schema.schema_id)