Open Arkemlar opened 1 year ago
Alternative way to set conf instance via setter injection:
Koco\Kafka\Messenger\KafkaTransportFactory:
... # config from https://github.com/KonstantinCodes/messenger-kafka/blob/master/src/Resources/config/services.xml
calls:
- setConfInstance: ["@=service('App\\\\DI\\\\KafkaTransportConfigurator').getConf()"]
Symfony docs about this feature.
But configurator looks better, it does not override original service
With optional constructor argument or setter injection in KafkaTransportFactory for RdKafka\Conf (imported as KafkaConf in that file) we could set any callbacks we want, and no extra PRs for callback support features needed.
Example/change proposal
Make these changes
THEN we can pass configured RdKafka\Conf instance.
How client code might look like
To pass RdKafka\Conf instance we would need to make only 2 steps: 1) First create configurator - a place that cooks our RdKafka\Conf instance
2) And define configurator for KafkaTransportFactory service
That must work. Symfony calls KafkaTransportConfigurator->__invoke() right after transport instance created and before it is used to produce transport.
This symfony container feature documented here