Effect CommunityEC
Effect Community3y ago
24 replies
kayng84

Basic KafkaService Layer with kafkajs library wrapper

hi mates, I make a very basic KafkaService Layer to wrap the kafkajs library. The code can be found here: https://gist.github.com/khoinguyen/39d2730dd567ccf2f3e397c62830bb1b

When run with ts-node, the program output but stuck there but not finished. The output copied at the end of the gist.

1. I think it should be gracefully finished after it produce the message, and run the Effect.onExit to clean up the producer. But it hang there
2. The onExit running should be after the result of send ? Here it is before, which mean the clean up start even before the promise finished?
3. NoSuchElementException, in the onExit, I want to disconnect consumer/producer when it is existed (Some), I think O.map do run the function only if self is Some, but here it is give a Cause of NoSuchElementException. Please help me to understand here.

Any support are appreciated!
Was this page helpful?