33using System . Text ;
44using System . Threading ;
55using ServiceStack . Logging ;
6- using ServiceStack . Text ;
76
87namespace ServiceStack . Redis
98{
@@ -29,6 +28,7 @@ public class RedisPubSubServer : IRedisPubSubServer
2928 public Action < string > OnUnSubscribe { get ; set ; }
3029 public Action < Exception > OnError { get ; set ; }
3130 public Action < IRedisPubSubServer > OnFailover { get ; set ; }
31+ public bool IsSentinelSubscription { get ; set ; }
3232
3333 readonly Random rand = new Random ( Environment . TickCount ) ;
3434
@@ -62,8 +62,10 @@ public long BgThreadCount
6262 get { return Interlocked . CompareExchange ( ref bgThreadCount , 0 , 0 ) ; }
6363 }
6464
65+ public const string AllChannelsWildCard = "*" ;
6566 public IRedisClientsManager ClientsManager { get ; set ; }
6667 public string [ ] Channels { get ; set ; }
68+ public string [ ] ChannelsMatching { get ; set ; }
6769 public TimeSpan ? WaitBeforeNextRestart { get ; set ; }
6870
6971 public RedisPubSubServer ( IRedisClientsManager clientsManager , params string [ ] channels )
@@ -141,7 +143,9 @@ private void Init()
141143 using ( var redis = ClientsManager . GetReadOnlyClient ( ) )
142144 {
143145 startedAt = Stopwatch . StartNew ( ) ;
144- serverTimeAtStart = redis . GetServerTime ( ) ;
146+ serverTimeAtStart = IsSentinelSubscription
147+ ? DateTime . UtcNow
148+ : redis . GetServerTime ( ) ;
145149 }
146150 }
147151 catch ( Exception ex )
@@ -281,7 +285,12 @@ private void RunLoop()
281285 }
282286 } ;
283287
284- subscription . SubscribeToChannels ( Channels ) ; //blocks thread
288+ //blocks thread
289+ if ( ChannelsMatching != null )
290+ subscription . SubscribeToChannelsMatching ( ChannelsMatching ) ;
291+ else
292+ subscription . SubscribeToChannels ( Channels ) ;
293+
285294 masterClient = null ;
286295 }
287296 }
0 commit comments