import warnings

# https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
librdkafka_configurations = {
	"builtin.features": "*",
	"client.id": "*",
	"metadata.broker.list": "*",
	"bootstrap.servers": "*",
	"message.max.bytes": "*",
	"message.copy.max.bytes": "*",
	"receive.message.max.bytes": "*",
	"max.in.flight.requests.per.connection": "*",
	"max.in.flight": "*",
	"topic.metadata.refresh.interval.ms": "*",
	"metadata.max.age.ms": "*",
	"topic.metadata.refresh.fast.interval.ms": "*",
	"topic.metadata.refresh.fast.cnt": "*",
	"topic.metadata.refresh.sparse": "*",
	"topic.metadata.propagation.max.ms": "*",
	"topic.blacklist": "*",
	"debug": "*",
	"socket.timeout.ms": "*",
	"socket.blocking.max.ms": "*",
	"socket.send.buffer.bytes": "*",
	"socket.receive.buffer.bytes": "*",
	"socket.keepalive.enable": "*",
	"socket.nagle.disable": "*",
	"socket.max.fails": "*",
	"broker.address.ttl": "*",
	"broker.address.family": "*",
	"connections.max.idle.ms": "*",
	"reconnect.backoff.jitter.ms": "*",
	"reconnect.backoff.ms": "*",
	"reconnect.backoff.max.ms": "*",
	"statistics.interval.ms": "*",
	"enabled_events": "*",
	"error_cb": "*",
	"throttle_cb": "*",
	"stats_cb": "*",
	"log_cb": "*",
	"log_level": "*",
	"log.queue": "*",
	"log.thread.name": "*",
	"enable.random.seed": "*",
	"log.connection.close": "*",
	"background_event_cb": "*",
	"socket_cb": "*",
	"connect_cb": "*",
	"closesocket_cb": "*",
	"open_cb": "*",
	"opaque": "*",
	"default_topic_conf": "*",
	"internal.termination.signal": "*",
	"api.version.request": "*",
	"api.version.request.timeout.ms": "*",
	"api.version.fallback.ms": "*",
	"broker.version.fallback": "*",
	"security.protocol": "*",
	"ssl.cipher.suites": "*",
	"ssl.curves.list": "*",
	"ssl.sigalgs.list": "*",
	"ssl.key.location": "*",
	"ssl.key.password": "*",
	"ssl.key.pem": "*",
	"ssl_key": "*",
	"ssl.certificate.location": "*",
	"ssl.certificate.pem": "*",
	"ssl_certificate": "*",
	"ssl.ca.location": "*",
	"ssl_ca": "*",
	"ssl.ca.certificate.stores": "*",
	"ssl.crl.location": "*",
	"ssl.keystore.location": "*",
	"ssl.keystore.password": "*",
	"ssl.engine.location": "*",
	"ssl.engine.id": "*",
	"ssl_engine_callback_data": "*",
	"enable.ssl.certificate.verification": "*",
	"ssl.endpoint.identification.algorithm": "*",
	"ssl.certificate.verify_cb": "*",
	"sasl.mechanisms": "*",
	"sasl.mechanism": "*",
	"sasl.kerberos.service.name": "*",
	"sasl.kerberos.principal": "*",
	"sasl.kerberos.kinit.cmd": "*",
	"sasl.kerberos.keytab": "*",
	"sasl.kerberos.min.time.before.relogin": "*",
	"sasl.username": "*",
	"sasl.password": "*",
	"sasl.oauthbearer.config": "*",
	"enable.sasl.oauthbearer.unsecure.jwt": "*",
	"oauthbearer_token_refresh_cb": "*",
	"plugin.library.paths": "*",
	"interceptors": "*",
	"group.id": "C",
	"group.instance.id": "C",
	"partition.assignment.strategy": "C",
	"session.timeout.ms": "C",
	"heartbeat.interval.ms": "C",
	"group.protocol.type": "C",
	"coordinator.query.interval.ms": "C",
	"max.poll.interval.ms": "C",
	"enable.auto.commit": "C",
	"auto.commit.interval.ms": "C",
	"enable.auto.offset.store": "C",
	"queued.min.messages": "C",
	"queued.max.messages.kbytes": "C",
	"fetch.wait.max.ms": "C",
	"fetch.message.max.bytes": "C",
	"max.partition.fetch.bytes": "C",
	"fetch.max.bytes": "C",
	"fetch.min.bytes": "C",
	"fetch.error.backoff.ms": "C",
	"offset.store.method": "C",
	"isolation.level": "C",
	"consume_cb": "C",
	"rebalance_cb": "C",
	"offset_commit_cb": "C",
	"enable.partition.eof": "C",
	"check.crcs": "C",
	"allow.auto.create.topics": "C",
	"client.rack": "*",
	"transactional.id": "P",
	"transaction.timeout.ms": "P",
	"enable.idempotence": "P",
	"enable.gapless.guarantee": "P",
	"queue.buffering.max.messages": "P",
	"queue.buffering.max.kbytes": "P",
	"queue.buffering.max.ms": "P",
	"linger.ms": "P",
	"message.send.max.retries": "P",
	"retries": "P",
	"retry.backoff.ms": "P",
	"queue.buffering.backpressure.threshold": "P",
	"compression.codec": "P",
	"compression.type": "P",
	"batch.num.messages": "P",
	"batch.size": "P",
	"delivery.report.only.error": "P",
	"dr_cb": "P",
	"dr_msg_cb": "P",
	"sticky.partitioning.linger.ms": "P",
	"request.required.acks": "P",
	"acks": "P",
	"request.timeout.ms": "P",
	"message.timeout.ms": "P",
	"delivery.timeout.ms": "P",
	"queuing.strategy": "P",
	"produce.offset.report": "P",
	"partitioner": "P",
	"partitioner_cb": "P",
	"msg_order_cmp": "P",
	"opaque": "*",
	"compression.codec": "P",
	"compression.type": "P",
	"compression.level": "P",
	"auto.commit.enable": "C",
	"enable.auto.commit": "C",
	"auto.commit.interval.ms": "C",
	"auto.offset.reset": "C",
	"offset.store.path": "C",
	"offset.store.sync.interval.ms": "C",
	"offset.store.method": "C",
	"consume.callback.max.messages": "C",
}
for k,v in librdkafka_configurations.items():
	if v not in "*CP":
		warnings.warn(f"unknown librdkafka configuration {k}")

def split_props(mixed):
	C = {}
	P = {}
	B = {}
	for k,v in mixed.items():
		f = librdkafka_configurations.get(k)
		if f == "C":
			C[k] = v
		elif f == "P":
			P[k] = v
		else:
			B[k] = v
	
	return C, P, B
