# ToDo (tribunsky.kir): looks like that idea of dynamic import via imp depending on librdkafka
#                       wasn't the worst idea, cause `if`s causes a lot of static checks problems.
# mypy: disable-error-code="no-redef,assignment"

from wunderkafka import librdkafka

# Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
#   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
#   and we don't want to have a nice whitelist, which is arguable
COMMON_FIELDS = (
    'api.version.fallback.ms',
    'api.version.request',
    'api.version.request.timeout.ms',
    'background_event_cb',
    'bootstrap.servers',
    'broker.address.family',
    'broker.address.ttl',
    'broker.version.fallback',
    'builtin.features',
    'client.id',
    'client.rack',
    'closesocket_cb',
    'connect_cb',
    'debug',
    'default_topic_conf',
    'enable.sasl.oauthbearer.unsecure.jwt',
    'enable.ssl.certificate.verification',
    'enabled_events',
    'error_cb',
    'interceptors',
    'internal.termination.signal',
    'log.connection.close',
    'log.queue',
    'log.thread.name',
    'log_cb',
    'log_level',
    'max.in.flight',
    'max.in.flight.requests.per.connection',
    'message.copy.max.bytes',
    'message.max.bytes',
    'metadata.broker.list',
    'metadata.max.age.ms',
    'metadata.request.timeout.ms',
    'oauthbearer_token_refresh_cb',
    'opaque',
    'open_cb',
    'plugin.library.paths',
    'receive.message.max.bytes',
    'reconnect.backoff.max.ms',
    'reconnect.backoff.ms',
    'sasl.kerberos.keytab',
    'sasl.kerberos.kinit.cmd',
    'sasl.kerberos.min.time.before.relogin',
    'sasl.kerberos.principal',
    'sasl.kerberos.service.name',
    'sasl.mechanism',
    'sasl.mechanisms',
    'sasl.oauthbearer.config',
    'sasl.password',
    'sasl.username',
    'security.protocol',
    'socket.keepalive.enable',
    'socket.max.fails',
    'socket.nagle.disable',
    'socket.receive.buffer.bytes',
    'socket.send.buffer.bytes',
    'socket.timeout.ms',
    'socket_cb',
    'ssl.ca.location',
    'ssl.certificate.location',
    'ssl.certificate.pem',
    'ssl.certificate.verify_cb',
    'ssl.cipher.suites',
    'ssl.crl.location',
    'ssl.curves.list',
    'ssl.endpoint.identification.algorithm',
    'ssl.key.location',
    'ssl.key.password',
    'ssl.key.pem',
    'ssl.keystore.location',
    'ssl.keystore.password',
    'ssl.sigalgs.list',
    'ssl_ca',
    'ssl_certificate',
    'ssl_key',
    'statistics.interval.ms',
    'stats_cb',
    'throttle_cb',
    'topic.blacklist',
    'topic.metadata.refresh.fast.interval.ms',
    'topic.metadata.refresh.interval.ms',
    'topic.metadata.refresh.sparse',
)
CONSUMER_FIELDS = (
    'auto.commit.interval.ms',
    'auto.offset.reset',
    'check.crcs',
    'consume.callback.max.messages',
    'consume_cb',
    'coordinator.query.interval.ms',
    'enable.auto.commit',
    'enable.auto.offset.store',
    'enable.partition.eof',
    'fetch.error.backoff.ms',
    'fetch.max.bytes',
    'fetch.message.max.bytes',
    'fetch.min.bytes',
    'fetch.wait.max.ms',
    'group.id',
    'group.instance.id',
    'group.protocol.type',
    'heartbeat.interval.ms',
    'isolation.level',
    'max.partition.fetch.bytes',
    'max.poll.interval.ms',
    'offset_commit_cb',
    'partition.assignment.strategy',
    'queued.max.messages.kbytes',
    'queued.min.messages',
    'rebalance_cb',
    'session.timeout.ms',
)
PRODUCER_FIELDS = (
    'acks',
    'batch.num.messages',
    'compression.codec',
    'compression.level',
    'compression.type',
    'delivery.report.only.error',
    'delivery.timeout.ms',
    'dr_cb',
    'dr_msg_cb',
    'enable.gapless.guarantee',
    'enable.idempotence',
    'linger.ms',
    'message.send.max.retries',
    'message.timeout.ms',
    'msg_order_cmp',
    'partitioner',
    'partitioner_cb',
    'queue.buffering.backpressure.threshold',
    'queue.buffering.max.kbytes',
    'queue.buffering.max.messages',
    'queue.buffering.max.ms',
    'queuing.strategy',
    'request.required.acks',
    'request.timeout.ms',
    'retries',
    'retry.backoff.ms',
    'transaction.timeout.ms',
    'transactional.id',
)

if librdkafka.__version__ >= (1, 5, 0):
    # Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
    #   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
    #   and we don't want to have a nice whitelist, which is arguable
    COMMON_FIELDS = (
        'api.version.fallback.ms',
        'api.version.request',
        'api.version.request.timeout.ms',
        'background_event_cb',
        'bootstrap.servers',
        'broker.address.family',
        'broker.address.ttl',
        'broker.version.fallback',
        'builtin.features',
        'client.id',
        'client.rack',
        'closesocket_cb',
        'connect_cb',
        'debug',
        'default_topic_conf',
        'enable.random.seed',
        'enable.sasl.oauthbearer.unsecure.jwt',
        'enable.ssl.certificate.verification',
        'enabled_events',
        'error_cb',
        'interceptors',
        'internal.termination.signal',
        'log.connection.close',
        'log.queue',
        'log.thread.name',
        'log_cb',
        'log_level',
        'max.in.flight',
        'max.in.flight.requests.per.connection',
        'message.copy.max.bytes',
        'message.max.bytes',
        'metadata.broker.list',
        'metadata.max.age.ms',
        'metadata.request.timeout.ms',
        'oauthbearer_token_refresh_cb',
        'opaque',
        'open_cb',
        'plugin.library.paths',
        'receive.message.max.bytes',
        'reconnect.backoff.max.ms',
        'reconnect.backoff.ms',
        'sasl.kerberos.keytab',
        'sasl.kerberos.kinit.cmd',
        'sasl.kerberos.min.time.before.relogin',
        'sasl.kerberos.principal',
        'sasl.kerberos.service.name',
        'sasl.mechanism',
        'sasl.mechanisms',
        'sasl.oauthbearer.config',
        'sasl.password',
        'sasl.username',
        'security.protocol',
        'socket.keepalive.enable',
        'socket.max.fails',
        'socket.nagle.disable',
        'socket.receive.buffer.bytes',
        'socket.send.buffer.bytes',
        'socket.timeout.ms',
        'socket_cb',
        'ssl.ca.location',
        'ssl.certificate.location',
        'ssl.certificate.pem',
        'ssl.certificate.verify_cb',
        'ssl.cipher.suites',
        'ssl.crl.location',
        'ssl.curves.list',
        'ssl.endpoint.identification.algorithm',
        'ssl.key.location',
        'ssl.key.password',
        'ssl.key.pem',
        'ssl.keystore.location',
        'ssl.keystore.password',
        'ssl.sigalgs.list',
        'ssl_ca',
        'ssl_certificate',
        'ssl_key',
        'statistics.interval.ms',
        'stats_cb',
        'throttle_cb',
        'topic.blacklist',
        'topic.metadata.propagation.max.ms',
        'topic.metadata.refresh.fast.interval.ms',
        'topic.metadata.refresh.interval.ms',
        'topic.metadata.refresh.sparse',
    )
    CONSUMER_FIELDS = (
        'allow.auto.create.topics',
        'auto.commit.interval.ms',
        'auto.offset.reset',
        'check.crcs',
        'consume.callback.max.messages',
        'consume_cb',
        'coordinator.query.interval.ms',
        'enable.auto.commit',
        'enable.auto.offset.store',
        'enable.partition.eof',
        'fetch.error.backoff.ms',
        'fetch.max.bytes',
        'fetch.message.max.bytes',
        'fetch.min.bytes',
        'fetch.wait.max.ms',
        'group.id',
        'group.instance.id',
        'group.protocol.type',
        'heartbeat.interval.ms',
        'isolation.level',
        'max.partition.fetch.bytes',
        'max.poll.interval.ms',
        'offset_commit_cb',
        'partition.assignment.strategy',
        'queued.max.messages.kbytes',
        'queued.min.messages',
        'rebalance_cb',
        'session.timeout.ms',
    )
    PRODUCER_FIELDS = (
        'acks',
        'batch.num.messages',
        'batch.size',
        'compression.codec',
        'compression.level',
        'compression.type',
        'delivery.report.only.error',
        'delivery.timeout.ms',
        'dr_cb',
        'dr_msg_cb',
        'enable.gapless.guarantee',
        'enable.idempotence',
        'linger.ms',
        'message.send.max.retries',
        'message.timeout.ms',
        'msg_order_cmp',
        'partitioner',
        'partitioner_cb',
        'queue.buffering.backpressure.threshold',
        'queue.buffering.max.kbytes',
        'queue.buffering.max.messages',
        'queue.buffering.max.ms',
        'queuing.strategy',
        'request.required.acks',
        'request.timeout.ms',
        'retries',
        'retry.backoff.ms',
        'transaction.timeout.ms',
        'transactional.id',
    )

if librdkafka.__version__ >= (1, 6, 0):
    # Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
    #   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
    #   and we don't want to have a nice whitelist, which is arguable
    COMMON_FIELDS = (
        'api.version.fallback.ms',
        'api.version.request',
        'api.version.request.timeout.ms',
        'background_event_cb',
        'bootstrap.servers',
        'broker.address.family',
        'broker.address.ttl',
        'broker.version.fallback',
        'builtin.features',
        'client.id',
        'client.rack',
        'closesocket_cb',
        'connect_cb',
        'debug',
        'default_topic_conf',
        'enable.random.seed',
        'enable.sasl.oauthbearer.unsecure.jwt',
        'enable.ssl.certificate.verification',
        'enabled_events',
        'error_cb',
        'interceptors',
        'internal.termination.signal',
        'log.connection.close',
        'log.queue',
        'log.thread.name',
        'log_cb',
        'log_level',
        'max.in.flight',
        'max.in.flight.requests.per.connection',
        'message.copy.max.bytes',
        'message.max.bytes',
        'metadata.broker.list',
        'metadata.max.age.ms',
        'metadata.request.timeout.ms',
        'oauthbearer_token_refresh_cb',
        'opaque',
        'open_cb',
        'plugin.library.paths',
        'receive.message.max.bytes',
        'reconnect.backoff.max.ms',
        'reconnect.backoff.ms',
        'sasl.kerberos.keytab',
        'sasl.kerberos.kinit.cmd',
        'sasl.kerberos.min.time.before.relogin',
        'sasl.kerberos.principal',
        'sasl.kerberos.service.name',
        'sasl.mechanism',
        'sasl.mechanisms',
        'sasl.oauthbearer.config',
        'sasl.password',
        'sasl.username',
        'security.protocol',
        'socket.keepalive.enable',
        'socket.max.fails',
        'socket.nagle.disable',
        'socket.receive.buffer.bytes',
        'socket.send.buffer.bytes',
        'socket.timeout.ms',
        'socket_cb',
        'ssl.ca.certificate.stores',
        'ssl.ca.location',
        'ssl.certificate.location',
        'ssl.certificate.pem',
        'ssl.certificate.verify_cb',
        'ssl.cipher.suites',
        'ssl.crl.location',
        'ssl.curves.list',
        'ssl.endpoint.identification.algorithm',
        'ssl.key.location',
        'ssl.key.password',
        'ssl.key.pem',
        'ssl.keystore.location',
        'ssl.keystore.password',
        'ssl.sigalgs.list',
        'ssl_ca',
        'ssl_certificate',
        'ssl_key',
        'statistics.interval.ms',
        'stats_cb',
        'throttle_cb',
        'topic.blacklist',
        'topic.metadata.propagation.max.ms',
        'topic.metadata.refresh.fast.interval.ms',
        'topic.metadata.refresh.interval.ms',
        'topic.metadata.refresh.sparse',
    )
    CONSUMER_FIELDS = (
        'allow.auto.create.topics',
        'auto.commit.interval.ms',
        'auto.offset.reset',
        'check.crcs',
        'consume.callback.max.messages',
        'consume_cb',
        'coordinator.query.interval.ms',
        'enable.auto.commit',
        'enable.auto.offset.store',
        'enable.partition.eof',
        'fetch.error.backoff.ms',
        'fetch.max.bytes',
        'fetch.message.max.bytes',
        'fetch.min.bytes',
        'fetch.wait.max.ms',
        'group.id',
        'group.instance.id',
        'group.protocol.type',
        'heartbeat.interval.ms',
        'isolation.level',
        'max.partition.fetch.bytes',
        'max.poll.interval.ms',
        'offset_commit_cb',
        'partition.assignment.strategy',
        'queued.max.messages.kbytes',
        'queued.min.messages',
        'rebalance_cb',
        'session.timeout.ms',
    )
    PRODUCER_FIELDS = (
        'acks',
        'batch.num.messages',
        'batch.size',
        'compression.codec',
        'compression.level',
        'compression.type',
        'delivery.report.only.error',
        'delivery.timeout.ms',
        'dr_cb',
        'dr_msg_cb',
        'enable.gapless.guarantee',
        'enable.idempotence',
        'linger.ms',
        'message.send.max.retries',
        'message.timeout.ms',
        'msg_order_cmp',
        'partitioner',
        'partitioner_cb',
        'queue.buffering.backpressure.threshold',
        'queue.buffering.max.kbytes',
        'queue.buffering.max.messages',
        'queue.buffering.max.ms',
        'queuing.strategy',
        'request.required.acks',
        'request.timeout.ms',
        'retries',
        'retry.backoff.ms',
        'sticky.partitioning.linger.ms',
        'transaction.timeout.ms',
        'transactional.id',
    )

if librdkafka.__version__ >= (1, 7, 0):
    # Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
    #   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
    #   and we don't want to have a nice whitelist, which is arguable
    COMMON_FIELDS = (
        'api.version.fallback.ms',
        'api.version.request',
        'api.version.request.timeout.ms',
        'background_event_cb',
        'bootstrap.servers',
        'broker.address.family',
        'broker.address.ttl',
        'broker.version.fallback',
        'builtin.features',
        'client.id',
        'client.rack',
        'closesocket_cb',
        'connect_cb',
        'connections.max.idle.ms',
        'debug',
        'default_topic_conf',
        'enable.random.seed',
        'enable.sasl.oauthbearer.unsecure.jwt',
        'enable.ssl.certificate.verification',
        'enabled_events',
        'error_cb',
        'interceptors',
        'internal.termination.signal',
        'log.connection.close',
        'log.queue',
        'log.thread.name',
        'log_cb',
        'log_level',
        'max.in.flight',
        'max.in.flight.requests.per.connection',
        'message.copy.max.bytes',
        'message.max.bytes',
        'metadata.broker.list',
        'metadata.max.age.ms',
        'oauthbearer_token_refresh_cb',
        'opaque',
        'open_cb',
        'plugin.library.paths',
        'receive.message.max.bytes',
        'reconnect.backoff.max.ms',
        'reconnect.backoff.ms',
        'sasl.kerberos.keytab',
        'sasl.kerberos.kinit.cmd',
        'sasl.kerberos.min.time.before.relogin',
        'sasl.kerberos.principal',
        'sasl.kerberos.service.name',
        'sasl.mechanism',
        'sasl.mechanisms',
        'sasl.oauthbearer.config',
        'sasl.password',
        'sasl.username',
        'security.protocol',
        'socket.keepalive.enable',
        'socket.max.fails',
        'socket.nagle.disable',
        'socket.receive.buffer.bytes',
        'socket.send.buffer.bytes',
        'socket.timeout.ms',
        'socket_cb',
        'ssl.ca.certificate.stores',
        'ssl.ca.location',
        'ssl.certificate.location',
        'ssl.certificate.pem',
        'ssl.certificate.verify_cb',
        'ssl.cipher.suites',
        'ssl.crl.location',
        'ssl.curves.list',
        'ssl.endpoint.identification.algorithm',
        'ssl.engine.id',
        'ssl.engine.location',
        'ssl.key.location',
        'ssl.key.password',
        'ssl.key.pem',
        'ssl.keystore.location',
        'ssl.keystore.password',
        'ssl.sigalgs.list',
        'ssl_ca',
        'ssl_certificate',
        'ssl_engine_callback_data',
        'ssl_key',
        'statistics.interval.ms',
        'stats_cb',
        'throttle_cb',
        'topic.blacklist',
        'topic.metadata.propagation.max.ms',
        'topic.metadata.refresh.fast.interval.ms',
        'topic.metadata.refresh.interval.ms',
        'topic.metadata.refresh.sparse',
    )
    CONSUMER_FIELDS = (
        'allow.auto.create.topics',
        'auto.commit.interval.ms',
        'auto.offset.reset',
        'check.crcs',
        'consume.callback.max.messages',
        'consume_cb',
        'coordinator.query.interval.ms',
        'enable.auto.commit',
        'enable.auto.offset.store',
        'enable.partition.eof',
        'fetch.error.backoff.ms',
        'fetch.max.bytes',
        'fetch.message.max.bytes',
        'fetch.min.bytes',
        'fetch.wait.max.ms',
        'group.id',
        'group.instance.id',
        'group.protocol.type',
        'heartbeat.interval.ms',
        'isolation.level',
        'max.partition.fetch.bytes',
        'max.poll.interval.ms',
        'offset_commit_cb',
        'partition.assignment.strategy',
        'queued.max.messages.kbytes',
        'queued.min.messages',
        'rebalance_cb',
        'session.timeout.ms',
    )
    PRODUCER_FIELDS = (
        'acks',
        'batch.num.messages',
        'batch.size',
        'compression.codec',
        'compression.level',
        'compression.type',
        'delivery.report.only.error',
        'delivery.timeout.ms',
        'dr_cb',
        'dr_msg_cb',
        'enable.gapless.guarantee',
        'enable.idempotence',
        'linger.ms',
        'message.send.max.retries',
        'message.timeout.ms',
        'msg_order_cmp',
        'partitioner',
        'partitioner_cb',
        'queue.buffering.backpressure.threshold',
        'queue.buffering.max.kbytes',
        'queue.buffering.max.messages',
        'queue.buffering.max.ms',
        'queuing.strategy',
        'request.required.acks',
        'request.timeout.ms',
        'retries',
        'retry.backoff.ms',
        'sticky.partitioning.linger.ms',
        'transaction.timeout.ms',
        'transactional.id',
    )

if librdkafka.__version__ >= (1, 8, 0):
    # Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
    #   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
    #   and we don't want to have a nice whitelist, which is arguable
    COMMON_FIELDS = (
        'api.version.fallback.ms',
        'api.version.request',
        'api.version.request.timeout.ms',
        'background_event_cb',
        'bootstrap.servers',
        'broker.address.family',
        'broker.address.ttl',
        'broker.version.fallback',
        'builtin.features',
        'client.id',
        'client.rack',
        'closesocket_cb',
        'connect_cb',
        'connections.max.idle.ms',
        'debug',
        'default_topic_conf',
        'enable.random.seed',
        'enable.sasl.oauthbearer.unsecure.jwt',
        'enable.ssl.certificate.verification',
        'enabled_events',
        'error_cb',
        'interceptors',
        'internal.termination.signal',
        'log.connection.close',
        'log.queue',
        'log.thread.name',
        'log_cb',
        'log_level',
        'max.in.flight',
        'max.in.flight.requests.per.connection',
        'message.copy.max.bytes',
        'message.max.bytes',
        'metadata.broker.list',
        'metadata.max.age.ms',
        'oauthbearer_token_refresh_cb',
        'opaque',
        'open_cb',
        'plugin.library.paths',
        'receive.message.max.bytes',
        'reconnect.backoff.max.ms',
        'reconnect.backoff.ms',
        'sasl.kerberos.keytab',
        'sasl.kerberos.kinit.cmd',
        'sasl.kerberos.min.time.before.relogin',
        'sasl.kerberos.principal',
        'sasl.kerberos.service.name',
        'sasl.mechanism',
        'sasl.mechanisms',
        'sasl.oauthbearer.config',
        'sasl.password',
        'sasl.username',
        'security.protocol',
        'socket.keepalive.enable',
        'socket.max.fails',
        'socket.nagle.disable',
        'socket.receive.buffer.bytes',
        'socket.send.buffer.bytes',
        'socket.timeout.ms',
        'socket_cb',
        'ssl.ca.certificate.stores',
        'ssl.ca.location',
        'ssl.certificate.location',
        'ssl.certificate.pem',
        'ssl.certificate.verify_cb',
        'ssl.cipher.suites',
        'ssl.crl.location',
        'ssl.curves.list',
        'ssl.endpoint.identification.algorithm',
        'ssl.engine.id',
        'ssl.engine.location',
        'ssl.key.location',
        'ssl.key.password',
        'ssl.key.pem',
        'ssl.keystore.location',
        'ssl.keystore.password',
        'ssl.sigalgs.list',
        'ssl_ca',
        'ssl_certificate',
        'ssl_engine_callback_data',
        'ssl_key',
        'statistics.interval.ms',
        'stats_cb',
        'throttle_cb',
        'topic.blacklist',
        'topic.metadata.propagation.max.ms',
        'topic.metadata.refresh.fast.interval.ms',
        'topic.metadata.refresh.interval.ms',
        'topic.metadata.refresh.sparse',
    )
    CONSUMER_FIELDS = (
        'allow.auto.create.topics',
        'auto.commit.interval.ms',
        'auto.offset.reset',
        'check.crcs',
        'consume.callback.max.messages',
        'consume_cb',
        'coordinator.query.interval.ms',
        'enable.auto.commit',
        'enable.auto.offset.store',
        'enable.partition.eof',
        'fetch.error.backoff.ms',
        'fetch.max.bytes',
        'fetch.message.max.bytes',
        'fetch.min.bytes',
        'fetch.wait.max.ms',
        'group.id',
        'group.instance.id',
        'group.protocol.type',
        'heartbeat.interval.ms',
        'isolation.level',
        'max.partition.fetch.bytes',
        'max.poll.interval.ms',
        'offset_commit_cb',
        'partition.assignment.strategy',
        'queued.max.messages.kbytes',
        'queued.min.messages',
        'rebalance_cb',
        'session.timeout.ms',
    )
    PRODUCER_FIELDS = (
        'acks',
        'batch.num.messages',
        'batch.size',
        'compression.codec',
        'compression.level',
        'compression.type',
        'delivery.report.only.error',
        'delivery.timeout.ms',
        'dr_cb',
        'dr_msg_cb',
        'enable.gapless.guarantee',
        'enable.idempotence',
        'linger.ms',
        'message.send.max.retries',
        'message.timeout.ms',
        'msg_order_cmp',
        'partitioner',
        'partitioner_cb',
        'queue.buffering.backpressure.threshold',
        'queue.buffering.max.kbytes',
        'queue.buffering.max.messages',
        'queue.buffering.max.ms',
        'queuing.strategy',
        'request.required.acks',
        'request.timeout.ms',
        'retries',
        'retry.backoff.ms',
        'sticky.partitioning.linger.ms',
        'transaction.timeout.ms',
        'transactional.id',
    )

if librdkafka.__version__ >= (1, 9, 0):
    # Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
    #   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
    #   and we don't want to have a nice whitelist, which is arguable
    COMMON_FIELDS = (
        'api.version.fallback.ms',
        'api.version.request',
        'api.version.request.timeout.ms',
        'background_event_cb',
        'bootstrap.servers',
        'broker.address.family',
        'broker.address.ttl',
        'broker.version.fallback',
        'builtin.features',
        'client.id',
        'client.rack',
        'closesocket_cb',
        'connect_cb',
        'connections.max.idle.ms',
        'debug',
        'default_topic_conf',
        'enable.random.seed',
        'enable.sasl.oauthbearer.unsecure.jwt',
        'enable.ssl.certificate.verification',
        'enabled_events',
        'error_cb',
        'interceptors',
        'internal.termination.signal',
        'log.connection.close',
        'log.queue',
        'log.thread.name',
        'log_cb',
        'log_level',
        'max.in.flight',
        'max.in.flight.requests.per.connection',
        'message.copy.max.bytes',
        'message.max.bytes',
        'metadata.broker.list',
        'metadata.max.age.ms',
        'oauthbearer_token_refresh_cb',
        'opaque',
        'open_cb',
        'plugin.library.paths',
        'receive.message.max.bytes',
        'reconnect.backoff.max.ms',
        'reconnect.backoff.ms',
        'sasl.kerberos.keytab',
        'sasl.kerberos.kinit.cmd',
        'sasl.kerberos.min.time.before.relogin',
        'sasl.kerberos.principal',
        'sasl.kerberos.service.name',
        'sasl.mechanism',
        'sasl.mechanisms',
        'sasl.oauthbearer.client.id',
        'sasl.oauthbearer.client.secret',
        'sasl.oauthbearer.config',
        'sasl.oauthbearer.extensions',
        'sasl.oauthbearer.method',
        'sasl.oauthbearer.scope',
        'sasl.oauthbearer.token.endpoint.url',
        'sasl.password',
        'sasl.username',
        'security.protocol',
        'socket.connection.setup.timeout.ms',
        'socket.keepalive.enable',
        'socket.max.fails',
        'socket.nagle.disable',
        'socket.receive.buffer.bytes',
        'socket.send.buffer.bytes',
        'socket.timeout.ms',
        'socket_cb',
        'ssl.ca.certificate.stores',
        'ssl.ca.location',
        'ssl.ca.pem',
        'ssl.certificate.location',
        'ssl.certificate.pem',
        'ssl.certificate.verify_cb',
        'ssl.cipher.suites',
        'ssl.crl.location',
        'ssl.curves.list',
        'ssl.endpoint.identification.algorithm',
        'ssl.engine.id',
        'ssl.engine.location',
        'ssl.key.location',
        'ssl.key.password',
        'ssl.key.pem',
        'ssl.keystore.location',
        'ssl.keystore.password',
        'ssl.sigalgs.list',
        'ssl_ca',
        'ssl_certificate',
        'ssl_engine_callback_data',
        'ssl_key',
        'statistics.interval.ms',
        'stats_cb',
        'throttle_cb',
        'topic.blacklist',
        'topic.metadata.propagation.max.ms',
        'topic.metadata.refresh.fast.interval.ms',
        'topic.metadata.refresh.interval.ms',
        'topic.metadata.refresh.sparse',
    )
    CONSUMER_FIELDS = (
        'allow.auto.create.topics',
        'auto.commit.interval.ms',
        'auto.offset.reset',
        'check.crcs',
        'consume.callback.max.messages',
        'consume_cb',
        'coordinator.query.interval.ms',
        'enable.auto.commit',
        'enable.auto.offset.store',
        'enable.partition.eof',
        'fetch.error.backoff.ms',
        'fetch.max.bytes',
        'fetch.message.max.bytes',
        'fetch.min.bytes',
        'fetch.wait.max.ms',
        'group.id',
        'group.instance.id',
        'group.protocol.type',
        'heartbeat.interval.ms',
        'isolation.level',
        'max.partition.fetch.bytes',
        'max.poll.interval.ms',
        'offset_commit_cb',
        'partition.assignment.strategy',
        'queued.max.messages.kbytes',
        'queued.min.messages',
        'rebalance_cb',
        'session.timeout.ms',
    )
    PRODUCER_FIELDS = (
        'acks',
        'batch.num.messages',
        'batch.size',
        'compression.codec',
        'compression.level',
        'compression.type',
        'delivery.report.only.error',
        'delivery.timeout.ms',
        'dr_cb',
        'dr_msg_cb',
        'enable.gapless.guarantee',
        'enable.idempotence',
        'linger.ms',
        'message.send.max.retries',
        'message.timeout.ms',
        'msg_order_cmp',
        'partitioner',
        'partitioner_cb',
        'queue.buffering.backpressure.threshold',
        'queue.buffering.max.kbytes',
        'queue.buffering.max.messages',
        'queue.buffering.max.ms',
        'queuing.strategy',
        'request.required.acks',
        'request.timeout.ms',
        'retries',
        'retry.backoff.ms',
        'sticky.partitioning.linger.ms',
        'transaction.timeout.ms',
        'transactional.id',
    )

if librdkafka.__version__ >= (2, 0, 0):
    # Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
    #   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
    #   and we don't want to have a nice whitelist, which is arguable
    COMMON_FIELDS = (
        'allow.auto.create.topics',
        'api.version.fallback.ms',
        'api.version.request',
        'api.version.request.timeout.ms',
        'background_event_cb',
        'bootstrap.servers',
        'broker.address.family',
        'broker.address.ttl',
        'broker.version.fallback',
        'builtin.features',
        'client.id',
        'client.rack',
        'closesocket_cb',
        'connect_cb',
        'connections.max.idle.ms',
        'debug',
        'default_topic_conf',
        'enable.random.seed',
        'enable.sasl.oauthbearer.unsecure.jwt',
        'enable.ssl.certificate.verification',
        'enabled_events',
        'error_cb',
        'interceptors',
        'internal.termination.signal',
        'log.connection.close',
        'log.queue',
        'log.thread.name',
        'log_cb',
        'log_level',
        'max.in.flight',
        'max.in.flight.requests.per.connection',
        'message.copy.max.bytes',
        'message.max.bytes',
        'metadata.broker.list',
        'metadata.max.age.ms',
        'oauthbearer_token_refresh_cb',
        'opaque',
        'open_cb',
        'plugin.library.paths',
        'receive.message.max.bytes',
        'reconnect.backoff.max.ms',
        'reconnect.backoff.ms',
        'resolve_cb',
        'sasl.kerberos.keytab',
        'sasl.kerberos.kinit.cmd',
        'sasl.kerberos.min.time.before.relogin',
        'sasl.kerberos.principal',
        'sasl.kerberos.service.name',
        'sasl.mechanism',
        'sasl.mechanisms',
        'sasl.oauthbearer.client.id',
        'sasl.oauthbearer.client.secret',
        'sasl.oauthbearer.config',
        'sasl.oauthbearer.extensions',
        'sasl.oauthbearer.method',
        'sasl.oauthbearer.scope',
        'sasl.oauthbearer.token.endpoint.url',
        'sasl.password',
        'sasl.username',
        'security.protocol',
        'socket.connection.setup.timeout.ms',
        'socket.keepalive.enable',
        'socket.max.fails',
        'socket.nagle.disable',
        'socket.receive.buffer.bytes',
        'socket.send.buffer.bytes',
        'socket.timeout.ms',
        'socket_cb',
        'ssl.ca.certificate.stores',
        'ssl.ca.location',
        'ssl.ca.pem',
        'ssl.certificate.location',
        'ssl.certificate.pem',
        'ssl.certificate.verify_cb',
        'ssl.cipher.suites',
        'ssl.crl.location',
        'ssl.curves.list',
        'ssl.endpoint.identification.algorithm',
        'ssl.engine.id',
        'ssl.key.location',
        'ssl.key.password',
        'ssl.key.pem',
        'ssl.keystore.location',
        'ssl.keystore.password',
        'ssl.providers',
        'ssl.sigalgs.list',
        'ssl_ca',
        'ssl_certificate',
        'ssl_engine_callback_data',
        'ssl_key',
        'statistics.interval.ms',
        'stats_cb',
        'throttle_cb',
        'topic.blacklist',
        'topic.metadata.propagation.max.ms',
        'topic.metadata.refresh.fast.interval.ms',
        'topic.metadata.refresh.interval.ms',
        'topic.metadata.refresh.sparse',
    )
    CONSUMER_FIELDS = (
        'auto.commit.interval.ms',
        'auto.offset.reset',
        'check.crcs',
        'consume.callback.max.messages',
        'consume_cb',
        'coordinator.query.interval.ms',
        'enable.auto.commit',
        'enable.auto.offset.store',
        'enable.partition.eof',
        'fetch.error.backoff.ms',
        'fetch.max.bytes',
        'fetch.message.max.bytes',
        'fetch.min.bytes',
        'fetch.wait.max.ms',
        'group.id',
        'group.instance.id',
        'group.protocol.type',
        'heartbeat.interval.ms',
        'isolation.level',
        'max.partition.fetch.bytes',
        'max.poll.interval.ms',
        'offset_commit_cb',
        'partition.assignment.strategy',
        'queued.max.messages.kbytes',
        'queued.min.messages',
        'rebalance_cb',
        'session.timeout.ms',
    )
    PRODUCER_FIELDS = (
        'acks',
        'batch.num.messages',
        'batch.size',
        'compression.codec',
        'compression.level',
        'compression.type',
        'delivery.report.only.error',
        'delivery.timeout.ms',
        'dr_cb',
        'dr_msg_cb',
        'enable.gapless.guarantee',
        'enable.idempotence',
        'linger.ms',
        'message.send.max.retries',
        'message.timeout.ms',
        'msg_order_cmp',
        'partitioner',
        'partitioner_cb',
        'queue.buffering.backpressure.threshold',
        'queue.buffering.max.kbytes',
        'queue.buffering.max.messages',
        'queue.buffering.max.ms',
        'queuing.strategy',
        'request.required.acks',
        'request.timeout.ms',
        'retries',
        'retry.backoff.ms',
        'sticky.partitioning.linger.ms',
        'transaction.timeout.ms',
        'transactional.id',
    )

if librdkafka.__version__ >= (2, 1, 0):
    # Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
    #   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
    #   and we don't want to have a nice whitelist, which is arguable
    COMMON_FIELDS = (
        'allow.auto.create.topics',
        'api.version.fallback.ms',
        'api.version.request',
        'api.version.request.timeout.ms',
        'background_event_cb',
        'bootstrap.servers',
        'broker.address.family',
        'broker.address.ttl',
        'broker.version.fallback',
        'builtin.features',
        'client.id',
        'client.rack',
        'closesocket_cb',
        'connect_cb',
        'connections.max.idle.ms',
        'debug',
        'default_topic_conf',
        'enable.random.seed',
        'enable.sasl.oauthbearer.unsecure.jwt',
        'enable.ssl.certificate.verification',
        'enabled_events',
        'error_cb',
        'interceptors',
        'internal.termination.signal',
        'log.connection.close',
        'log.queue',
        'log.thread.name',
        'log_cb',
        'log_level',
        'max.in.flight',
        'max.in.flight.requests.per.connection',
        'message.copy.max.bytes',
        'message.max.bytes',
        'metadata.broker.list',
        'metadata.max.age.ms',
        'oauthbearer_token_refresh_cb',
        'opaque',
        'open_cb',
        'plugin.library.paths',
        'receive.message.max.bytes',
        'reconnect.backoff.max.ms',
        'reconnect.backoff.ms',
        'resolve_cb',
        'sasl.kerberos.keytab',
        'sasl.kerberos.kinit.cmd',
        'sasl.kerberos.min.time.before.relogin',
        'sasl.kerberos.principal',
        'sasl.kerberos.service.name',
        'sasl.mechanism',
        'sasl.mechanisms',
        'sasl.oauthbearer.client.id',
        'sasl.oauthbearer.client.secret',
        'sasl.oauthbearer.config',
        'sasl.oauthbearer.extensions',
        'sasl.oauthbearer.method',
        'sasl.oauthbearer.scope',
        'sasl.oauthbearer.token.endpoint.url',
        'sasl.password',
        'sasl.username',
        'security.protocol',
        'socket.connection.setup.timeout.ms',
        'socket.keepalive.enable',
        'socket.max.fails',
        'socket.nagle.disable',
        'socket.receive.buffer.bytes',
        'socket.send.buffer.bytes',
        'socket.timeout.ms',
        'socket_cb',
        'ssl.ca.certificate.stores',
        'ssl.ca.location',
        'ssl.ca.pem',
        'ssl.certificate.location',
        'ssl.certificate.pem',
        'ssl.certificate.verify_cb',
        'ssl.cipher.suites',
        'ssl.crl.location',
        'ssl.curves.list',
        'ssl.endpoint.identification.algorithm',
        'ssl.engine.id',
        'ssl.key.location',
        'ssl.key.password',
        'ssl.key.pem',
        'ssl.keystore.location',
        'ssl.keystore.password',
        'ssl.providers',
        'ssl.sigalgs.list',
        'ssl_ca',
        'ssl_certificate',
        'ssl_engine_callback_data',
        'ssl_key',
        'statistics.interval.ms',
        'stats_cb',
        'throttle_cb',
        'topic.blacklist',
        'topic.metadata.propagation.max.ms',
        'topic.metadata.refresh.fast.interval.ms',
        'topic.metadata.refresh.interval.ms',
        'topic.metadata.refresh.sparse',
    )
    CONSUMER_FIELDS = (
        'auto.commit.interval.ms',
        'auto.offset.reset',
        'check.crcs',
        'consume.callback.max.messages',
        'consume_cb',
        'coordinator.query.interval.ms',
        'enable.auto.commit',
        'enable.auto.offset.store',
        'enable.partition.eof',
        'fetch.error.backoff.ms',
        'fetch.max.bytes',
        'fetch.message.max.bytes',
        'fetch.min.bytes',
        'fetch.wait.max.ms',
        'group.id',
        'group.instance.id',
        'group.protocol.type',
        'heartbeat.interval.ms',
        'isolation.level',
        'max.partition.fetch.bytes',
        'max.poll.interval.ms',
        'offset_commit_cb',
        'partition.assignment.strategy',
        'queued.max.messages.kbytes',
        'queued.min.messages',
        'rebalance_cb',
        'session.timeout.ms',
    )
    PRODUCER_FIELDS = (
        'acks',
        'batch.num.messages',
        'batch.size',
        'compression.codec',
        'compression.level',
        'compression.type',
        'delivery.report.only.error',
        'delivery.timeout.ms',
        'dr_cb',
        'dr_msg_cb',
        'enable.gapless.guarantee',
        'enable.idempotence',
        'linger.ms',
        'message.send.max.retries',
        'message.timeout.ms',
        'msg_order_cmp',
        'partitioner',
        'partitioner_cb',
        'queue.buffering.backpressure.threshold',
        'queue.buffering.max.kbytes',
        'queue.buffering.max.messages',
        'queue.buffering.max.ms',
        'queuing.strategy',
        'request.required.acks',
        'request.timeout.ms',
        'retries',
        'retry.backoff.ms',
        'sticky.partitioning.linger.ms',
        'transaction.timeout.ms',
        'transactional.id',
    )

if librdkafka.__version__ >= (2, 2, 0):
    # Why so: not all configuration parameters of librdkafka may be easily replaced from '_' to '.',
    #   therefore, we can't convert on-the-fly from  `ssl_ca` without errors
    #   and we don't want to have a nice whitelist, which is arguable
    COMMON_FIELDS = (
        'allow.auto.create.topics',
        'api.version.fallback.ms',
        'api.version.request',
        'api.version.request.timeout.ms',
        'background_event_cb',
        'bootstrap.servers',
        'broker.address.family',
        'broker.address.ttl',
        'broker.version.fallback',
        'builtin.features',
        'client.dns.lookup',
        'client.id',
        'client.rack',
        'closesocket_cb',
        'connect_cb',
        'connections.max.idle.ms',
        'debug',
        'default_topic_conf',
        'enable.random.seed',
        'enable.sasl.oauthbearer.unsecure.jwt',
        'enable.ssl.certificate.verification',
        'enabled_events',
        'error_cb',
        'interceptors',
        'internal.termination.signal',
        'log.connection.close',
        'log.queue',
        'log.thread.name',
        'log_cb',
        'log_level',
        'max.in.flight',
        'max.in.flight.requests.per.connection',
        'message.copy.max.bytes',
        'message.max.bytes',
        'metadata.broker.list',
        'metadata.max.age.ms',
        'oauthbearer_token_refresh_cb',
        'opaque',
        'open_cb',
        'plugin.library.paths',
        'receive.message.max.bytes',
        'reconnect.backoff.max.ms',
        'reconnect.backoff.ms',
        'resolve_cb',
        'sasl.kerberos.keytab',
        'sasl.kerberos.kinit.cmd',
        'sasl.kerberos.min.time.before.relogin',
        'sasl.kerberos.principal',
        'sasl.kerberos.service.name',
        'sasl.mechanism',
        'sasl.mechanisms',
        'sasl.oauthbearer.client.id',
        'sasl.oauthbearer.client.secret',
        'sasl.oauthbearer.config',
        'sasl.oauthbearer.extensions',
        'sasl.oauthbearer.method',
        'sasl.oauthbearer.scope',
        'sasl.oauthbearer.token.endpoint.url',
        'sasl.password',
        'sasl.username',
        'security.protocol',
        'socket.connection.setup.timeout.ms',
        'socket.keepalive.enable',
        'socket.max.fails',
        'socket.nagle.disable',
        'socket.receive.buffer.bytes',
        'socket.send.buffer.bytes',
        'socket.timeout.ms',
        'socket_cb',
        'ssl.ca.certificate.stores',
        'ssl.ca.location',
        'ssl.ca.pem',
        'ssl.certificate.location',
        'ssl.certificate.pem',
        'ssl.certificate.verify_cb',
        'ssl.cipher.suites',
        'ssl.crl.location',
        'ssl.curves.list',
        'ssl.endpoint.identification.algorithm',
        'ssl.engine.id',
        'ssl.key.location',
        'ssl.key.password',
        'ssl.key.pem',
        'ssl.keystore.location',
        'ssl.keystore.password',
        'ssl.providers',
        'ssl.sigalgs.list',
        'ssl_ca',
        'ssl_certificate',
        'ssl_engine_callback_data',
        'ssl_key',
        'statistics.interval.ms',
        'stats_cb',
        'throttle_cb',
        'topic.blacklist',
        'topic.metadata.propagation.max.ms',
        'topic.metadata.refresh.fast.interval.ms',
        'topic.metadata.refresh.interval.ms',
        'topic.metadata.refresh.sparse',
    )
    CONSUMER_FIELDS = (
        'auto.commit.interval.ms',
        'auto.offset.reset',
        'check.crcs',
        'consume.callback.max.messages',
        'consume_cb',
        'coordinator.query.interval.ms',
        'enable.auto.commit',
        'enable.auto.offset.store',
        'enable.partition.eof',
        'fetch.error.backoff.ms',
        'fetch.max.bytes',
        'fetch.message.max.bytes',
        'fetch.min.bytes',
        'fetch.queue.backoff.ms',
        'fetch.wait.max.ms',
        'group.id',
        'group.instance.id',
        'group.protocol.type',
        'heartbeat.interval.ms',
        'isolation.level',
        'max.partition.fetch.bytes',
        'max.poll.interval.ms',
        'offset_commit_cb',
        'partition.assignment.strategy',
        'queued.max.messages.kbytes',
        'queued.min.messages',
        'rebalance_cb',
        'session.timeout.ms',
    )
    PRODUCER_FIELDS = (
        'acks',
        'batch.num.messages',
        'batch.size',
        'compression.codec',
        'compression.level',
        'compression.type',
        'delivery.report.only.error',
        'delivery.timeout.ms',
        'dr_cb',
        'dr_msg_cb',
        'enable.gapless.guarantee',
        'enable.idempotence',
        'linger.ms',
        'message.send.max.retries',
        'message.timeout.ms',
        'msg_order_cmp',
        'partitioner',
        'partitioner_cb',
        'queue.buffering.backpressure.threshold',
        'queue.buffering.max.kbytes',
        'queue.buffering.max.messages',
        'queue.buffering.max.ms',
        'queuing.strategy',
        'request.required.acks',
        'request.timeout.ms',
        'retries',
        'retry.backoff.ms',
        'sticky.partitioning.linger.ms',
        'transaction.timeout.ms',
        'transactional.id',
    )

