jhutchison commented on a change in pull request #6493:
URL: https://github.com/apache/geode/pull/6493#discussion_r635363444



##########
File path: 
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/pubsub/Subscriptions.java
##########
@@ -67,6 +67,34 @@ boolean exists(Object channelOrPattern, Client client) {
         .collect(Collectors.toList());
   }
 
+  public List<byte[]> findChannelNames() {
+
+    return findChannels()
+        .stream()
+        .map(subscription -> (ChannelSubscription) subscription)
+        .map(ChannelSubscription::getSubscriptionName)
+        .distinct()
+        .collect(Collectors.toList());
+  }
+
+  public List<byte[]> findChannelNames(byte[] pattern) {
+    GlobPattern globPattern = new GlobPattern(new String(pattern));
+
+    return findChannels()
+        .stream()
+        .map(subscription -> (ChannelSubscription) subscription)
+        .filter(subscription -> globPattern.matches(new 
String(subscription.getSubscriptionName())))
+        .map(ChannelSubscription::getSubscriptionName)
+        .distinct()
+        .collect(Collectors.toList());
+  }
+
+  private List<Subscription> findChannels() {
+    return subscriptions.stream()
+        .filter(subscription -> subscription instanceof ChannelSubscription)
+        .collect(Collectors.toList());

Review comment:
       Ahh-- I do see that this allows to not have to cast the channels in the 
calling method though... I take it back, I like it better returning the 
ChannelSubscription...




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to