示例#1
0
文件: kafka.py 项目: disqus/pgshovel
def test_discarded_messages_is_configurable(configuration, cluster, client, state, writer, sliced_transaction):
    writer.push(sliced_transaction)

    configuration['prime_threshold'] = 1
    antsy_stream = KafkaStream.configure(configuration, cluster, 'default')

    less_antsy_config = configuration.copy()
    less_antsy_config['prime_threshold'] = 3
    less_antsy_stream = KafkaStream.configure(less_antsy_config, cluster, 'default')

    client.ensure_topic_exists(antsy_stream.topic)

    with pytest.raises(UnableToPrimeError):
        list(islice(antsy_stream.consume(state), 3))

    consumed = list(islice(less_antsy_stream.consume(state), 3))
    assert [message for _, _, message in consumed] == sliced_transaction[-3:]
示例#2
0
文件: kafka.py 项目: disqus/pgshovel
def stream(configuration, cluster, client):
    stream = KafkaStream.configure(configuration, cluster, 'default')
    client.ensure_topic_exists(stream.topic)
    yield stream