Skip to content
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

Consumer State Change Handling Feature #82

Merged
merged 19 commits into from Jan 31, 2022

Conversation

ronfarkash
Copy link
Collaborator

implements this #81

Allow the users of this library to "listen" to change in the consumer state without needing to check at intervals.

Since this PR isn't adding anything new to the consumer's logic, but just exports some of the inners nicely, I didn't add anything tests, open for suggestions though.

Copy link
Collaborator

@galrose galrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not add the onStateChange function to the constructor?
and there should be a basic test to make sure if runs the handler function successfully and an error if the handler function fails

src/consumer/index.js Show resolved Hide resolved
@galrose galrose self-assigned this Jan 18, 2022
@galrose galrose linked an issue Jan 18, 2022 that may be closed by this pull request
@galrose galrose added the enhancement New feature or request label Jan 18, 2022
Added array of consumers for preventing unnecessary code duplication in beforeEach() function in consumer tests
Added error handling for consumer state change function
Added 2 basic tests for consumer state change
… since it breaks reconnection error handling)
test/consumer/index-spec.js Outdated Show resolved Hide resolved
test/consumer/index-spec.js Show resolved Hide resolved
Copy link
Collaborator

@galrose galrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@danielsinai
Copy link
Collaborator

Wouldn't it be better to emit and event instead of injecting a function?

@ronfarkash
Copy link
Collaborator Author

Wouldn't it be better to emit and event instead of injecting a function?

Probably in the long run, for now this solution functions good enough. Might be a good idea to create an issue for it so it won't be forgotten.

@ronfarkash ronfarkash merged commit 4986bd9 into main Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consumer state change events
3 participants