@@ -9,6 +9,10 @@ internal sealed partial class MultiGroupSubscriber(MultiGroupMultiplexer parent,
99 // for a lot of things, we can defer through to the active implementation
1010 private ISubscriber GetActiveSubscriber ( ) => parent . Active . GetSubscriber ( asyncState ) ;
1111
12+ // non-throwing twin of GetActiveSubscriber: returns null when the group currently has no active
13+ // member, for use by members that have an obvious trivial result when disconnected
14+ private ISubscriber ? TryGetActiveSubscriber ( ) => parent . TryGetActive ( ) ? . GetSubscriber ( asyncState ) ;
15+
1216 public IConnectionMultiplexer Multiplexer => parent ;
1317
1418 public bool TryWait ( Task task ) => GetActiveSubscriber ( ) . TryWait ( task ) ;
@@ -24,18 +28,18 @@ internal sealed partial class MultiGroupSubscriber(MultiGroupMultiplexer parent,
2428 public Task < TimeSpan > PingAsync ( CommandFlags flags = CommandFlags . None ) => GetActiveSubscriber ( ) . PingAsync ( flags ) ;
2529
2630 public EndPoint ? IdentifyEndpoint ( RedisChannel channel , CommandFlags flags = CommandFlags . None ) =>
27- GetActiveSubscriber ( ) . IdentifyEndpoint ( channel , flags ) ;
31+ TryGetActiveSubscriber ( ) ? . IdentifyEndpoint ( channel , flags ) ;
2832
2933 public Task < EndPoint ? > IdentifyEndpointAsync ( RedisChannel channel , CommandFlags flags = CommandFlags . None ) =>
30- GetActiveSubscriber ( ) . IdentifyEndpointAsync ( channel , flags ) ;
34+ TryGetActiveSubscriber ( ) ? . IdentifyEndpointAsync ( channel , flags ) ?? MultiGroupMultiplexer . NoEndpoint ;
3135
32- public bool IsConnected ( RedisChannel channel = default ) => GetActiveSubscriber ( ) . IsConnected ( ) ;
36+ public bool IsConnected ( RedisChannel channel = default ) => TryGetActiveSubscriber ( ) ? . IsConnected ( ) ?? false ;
3337
3438 public long Publish ( RedisChannel channel , RedisValue message , CommandFlags flags = CommandFlags . None )
3539 => GetActiveSubscriber ( ) . Publish ( channel , message , flags ) ;
3640
3741 public Task < long > PublishAsync ( RedisChannel channel , RedisValue message , CommandFlags flags = CommandFlags . None )
3842 => GetActiveSubscriber ( ) . PublishAsync ( channel , message , flags ) ;
3943
40- public EndPoint ? SubscribedEndpoint ( RedisChannel channel ) => GetActiveSubscriber ( ) . SubscribedEndpoint ( channel ) ;
44+ public EndPoint ? SubscribedEndpoint ( RedisChannel channel ) => TryGetActiveSubscriber ( ) ? . SubscribedEndpoint ( channel ) ;
4145}
0 commit comments