Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Add method to list active users for a given flag #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/com/librato/rollout/RolloutClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public interface RolloutClient {
*/
boolean userFeatureActive(final String feature, long userId);

/**
* @param feature Rollout feature
* @return list of active user ids
*/
List<Long> activeUsers(final String feature);

/**
* @param feature Rollout feature
* @return Percentage of given feature, or 0 if feature does not exist
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/librato/rollout/zk/RolloutZKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public boolean userFeatureActive(String feature, long userId, List<String> userG
return false;
}

@Override
public List<Long> activeUsers(String feature) {
final Entry entry = features.get().get(feature);
return entry.userIds;
}

@Override
public void start() throws Exception {
if (!isStarted.compareAndSet(false, true)) {
Expand Down Expand Up @@ -156,7 +162,7 @@ public static Entry fromString(String s, String key) {
log.warn("Couldn't parse `{}` as a long, ignoring user id for key `{}`", id, key);
}
}
return new Entry(percentage, userIds, groups);
return new Entry(percentage, Collections.unmodifiableList(userIds), Collections.unmodifiableList(groups));
}
}
}