Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Exposes listeners in ConsulCache #136

Merged
merged 2 commits into from
Jun 4, 2016

Conversation

laissandrade
Copy link
Contributor

Hey, I was wondering if it's ok for you guys to expose the listeners from a ConsulCache. We need to access at least the number of listeners registered to a cache, so we can stop it once all listeners are removed, for example.

I've exposed in this pull request the size of the list, plus the list itself as an Iterable. Feel free to rename the methods if its not following your code pattern or something.

Thanks again!

@@ -202,6 +202,14 @@ public boolean addListener(Listener<K, V> listener) {
return added;
}

public Iterable<Listener<K, V>> getListeners() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest returning an ImmutableList or Collections.unmodifiable list here, it's generally iffy to give control of our member variables to other classes.

For example, if in the future additional logic is add in to addListener/removeListener then this could give people a way to remove listeners without triggering that logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can change that and even remove the count method, as we can expose the listeners as a list, not Iterable.

@rickfast rickfast merged commit 532cda2 into rickfast:master Jun 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants