neighbourhoodie / adonis-kafka-v6

MIT License
10 stars 0 forks source link

Feature: improve callback signatures #11

Closed ThisIsMissEm closed 6 months ago

ThisIsMissEm commented 6 months ago

This removes the resolveCallback logic, in favor of flat callbacks for now (pending the Consumer class implementation, which supersedes the .on(...) interface logic), and fixes all the callbacks to be correctly typed.

Additionally, I noticed that there was a potential error path where if a user forgot to call commit and autoCommit was false, then we'd get stuck — that now throws an error so that the application will crash. (expectation is you'll catch this in development/tests)

"Support" for regex topics is also explicitly dropped via the type signature of on(), whilst multiple topics support is now explicitly supported.

I've also split out the heartbeat and pause methods to explicit arguments of a topic subscription callback, as well as handling cases where an async callback may throw (this now triggers the error handler)