|
| 1 | +from conductor.client.event.queue.queue_configuration import QueueConfiguration |
| 2 | +from conductor.client.event.queue.queue_worker_configuration import QueueWorkerConfiguration |
| 3 | +from typing import Any, Dict |
| 4 | + |
| 5 | + |
| 6 | +class KafkaQueueConfiguration(QueueConfiguration): |
| 7 | + def __init__(self, queue_topic_name: str): |
| 8 | + super().__init__(queue_topic_name, 'kafka') |
| 9 | + |
| 10 | + def get_worker_configuration(self) -> Dict[str, Any]: |
| 11 | + worker_configuration = {} |
| 12 | + for required_key in ['consumer', 'producer']: |
| 13 | + if required_key not in self.worker_configuration: |
| 14 | + raise RuntimeError(f'required key not present: {required_key}') |
| 15 | + for key, value in self.worker_configuration.items(): |
| 16 | + worker_configuration[key] = value.configuration |
| 17 | + return worker_configuration |
| 18 | + |
| 19 | + |
| 20 | +class KafkaConsumerConfiguration(QueueWorkerConfiguration): |
| 21 | + def __init__(self, bootstrap_servers_config: str): |
| 22 | + super().__init__() |
| 23 | + super().add_configuration( |
| 24 | + key='bootstrap.servers', |
| 25 | + value=bootstrap_servers_config |
| 26 | + ) |
| 27 | + |
| 28 | + |
| 29 | +class KafkaProducerConfiguration(QueueWorkerConfiguration): |
| 30 | + def __init__(self, bootstrap_servers_config: str): |
| 31 | + super().__init__() |
| 32 | + super().add_configuration( |
| 33 | + key='bootstrap.servers', |
| 34 | + value=bootstrap_servers_config |
| 35 | + ) |
0 commit comments