def reader_test(topics, cons, messages, on_message, wait_on_messages): reader = AsyncMessageReader( SERVICE, config_topics, value_type=TEXT, consistency=consistency) reader.on_message = on_message reader.open() write_messages(messages, topics) wait_on_messages() reader.close()
def test_no_auth_async_read(setup_config): params = { 'sasl_plain_username': KAFKA_WRITE_USER, 'sasl_plain_password': KAFKA_WRITE_PASSWD, } error = 0 countdown = 1 cv = Condition() def error_handler(e, traceback=None): nonlocal countdown, error with cv: countdown -= 1 if isinstance(e, AuthorizationError): error += 1 cv.notify_all() reader = AsyncMessageReader(SERVICE, **params) reader.on_failure = error_handler reader.open() with cv: cv.wait(10) reader.close() assert error == 1
def consumer(service): reader = AsyncMessageReader(service) reader.on_message = show_message reader.open() wait_for_keyboard_interrupt() reader.close()