Skip to content

KafkaProducer.makeProducerWithEvents() avoid fatalError #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

felixschlegel
Copy link
Contributor

@felixschlegel felixschlegel commented Aug 18, 2023

Motivation:

KafkaProducer.makeeProducerWithEvents(): initializing the
NIOAsyncSequenceProducer before the clientand the client init throwing an erorr led to KafkaProducerCloseOnTerminate getting triggered in an invalid state which in turn resulted in a fatalError

Modifications:

  • make designated initializer of KafkaProducer non-throwing
  • KafkaProducer.makeProducerWithEvents:
    • initialize client before
      calling NIOAsyncSequenceProducer.makeSequence
      -> if initializing client fails the appropiate error gets thrown
      instead of triggering a fatalError because
      KafkaProducerCloseOnTerminate gets triggered in an invalid state

Result:

When the initialization KafkaProducer.makeProducerWithEvents fails an
error is thrown instead of triggering the fatalError in
KafkaProducerCloseOnTerminate.

Motivation:

`KafkaProducer.makeeProducerWithEvents()`: initializing the
`NIOAsyncSequenceProducer

Modifications:

* make designated initializer of `KafkaProducer` non-throwing
* `KafkaProducer.makeProducerWithEvents`:
    * initialize `client` before
      calling `NIOAsyncSequenceProducer.makeSequence`
      -> if initializing `client` fails the appropiate error gets thrown
         instead of triggering a fatalError because
         `KafkaProducerCloseOnTerminate` gets triggered in an invalid state

Result:

When the initialization `KafkaProducer.makeProducerWithEvents` fails an
error is thrown instead of triggering the `fatalError` in
`KafkaProducerCloseOnTerminate`.
@felixschlegel felixschlegel changed the title KafkaProducer.makeeProducerWithEvents() avoid fatalError KafkaProducer.makeProducerWithEvents() avoid fatalError Aug 18, 2023
@FranzBusch FranzBusch merged commit 20c7f54 into swift-server:main Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants