forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedisServerEvents.cs
More file actions
660 lines (539 loc) · 25.6 KB
/
Copy pathRedisServerEvents.cs
File metadata and controls
660 lines (539 loc) · 25.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ServiceStack.Logging;
using ServiceStack.Redis;
using ServiceStack.Text;
namespace ServiceStack
{
public class RedisServerEvents : IServerEvents
{
private static ILog Log = LogManager.GetLogger(typeof(RedisServerEvents));
public MemoryServerEvents Local { get; private set; }
public TimeSpan Timeout
{
get => Local.IdleTimeout;
set => Local.IdleTimeout = value;
}
public TimeSpan HouseKeepingInterval
{
get => Local.HouseKeepingInterval;
set => Local.HouseKeepingInterval = value;
}
public Func<IEventSubscription, Task> OnSubscribeAsync
{
get => Local.OnSubscribeAsync;
set => Local.OnSubscribeAsync = value;
}
public Func<IEventSubscription, Task> OnUnsubscribeAsync
{
get => Local.OnUnsubscribeAsync;
set => Local.OnUnsubscribeAsync = value;
}
public Func<IEventSubscription, Task> OnUpdateAsync
{
get => Local.OnUpdateAsync;
set => Local.OnUpdateAsync = value;
}
public bool NotifyChannelOfSubscriptions
{
get => Local.NotifyChannelOfSubscriptions;
set => Local.NotifyChannelOfSubscriptions = value;
}
public TimeSpan? WaitBeforeNextRestart
{
get => RedisPubSub.WaitBeforeNextRestart;
set => RedisPubSub.WaitBeforeNextRestart = value;
}
public static string Topic = "sse:topic";
public class RedisIndex
{
public static string Subscription = "sse:id:{0}";
public static string ActiveSubscriptionsSet = "sse:ids";
public static string ChannelSet = "sse:channel:{0}";
public static string UserIdSet = "sse:userid:{0}";
public static string UserNameSet = "sse:username:{0}";
public static string SessionSet = "sse:session:{0}";
}
public readonly IRedisClientsManager clientsManager;
public IRedisPubSubServer RedisPubSub { get; set; }
public RedisServerEvents(IRedisPubSubServer redisPubSub)
{
this.RedisPubSub = redisPubSub;
this.clientsManager = redisPubSub.ClientsManager;
redisPubSub.OnInit = OnInit;
redisPubSub.OnError = ex => Log.Error("Exception in RedisServerEvents: " + ex.Message, ex);
redisPubSub.OnMessage = HandleMessage;
WaitBeforeNextRestart = TimeSpan.FromMilliseconds(2000);
Local = new MemoryServerEvents
{
NotifyJoinAsync = HandleOnJoinAsync,
NotifyLeaveAsync = HandleOnLeaveAsync,
NotifyUpdateAsync = HandleOnUpdate,
NotifyHeartbeatAsync = NotifyHeartbeatAsync,
Serialize = HandleSerialize,
OnRemoveSubscriptionAsync = HandleOnRemoveSubscriptionAsync
};
var appHost = HostContext.AppHost;
var feature = appHost?.GetPlugin<ServerEventsFeature>();
if (feature != null)
{
Timeout = feature.IdleTimeout;
HouseKeepingInterval = feature.HouseKeepingInterval;
OnSubscribeAsync = feature.OnSubscribeAsync;
OnUnsubscribeAsync = feature.OnUnsubscribeAsync;
OnUpdateAsync = feature.OnUpdateAsync;
NotifyChannelOfSubscriptions = feature.NotifyChannelOfSubscriptions;
}
}
private Task HandleOnRemoveSubscriptionAsync(IEventSubscription sub)
{
var info = sub.GetInfo();
RemoveSubscriptionFromRedis(info);
return TypeConstants.EmptyTask;
}
private void OnInit()
{
UnRegisterExpiredSubscriptions();
}
public void UnRegisterExpiredSubscriptions()
{
using var redis = clientsManager.GetClient();
var lastPulseBefore = (RedisPubSub.CurrentServerTime - Timeout).Ticks;
var expiredSubIds = redis.GetRangeFromSortedSetByLowestScore(
RedisIndex.ActiveSubscriptionsSet, 0, lastPulseBefore);
UnRegisterSubIds(redis, expiredSubIds);
}
public void UnRegisterSubIds(IRedisClient redis, List<string> expiredSubIds)
{
foreach (var id in expiredSubIds)
{
NotifyRedis("unregister.id." + id, null, null);
}
//Force remove zombie subscriptions which have no listeners
var infos = GetSubscriptionInfos(redis, expiredSubIds);
foreach (var info in infos)
{
RemoveSubscriptionFromRedis(info);
}
}
private static List<SubscriptionInfo> GetSubscriptionInfos(IRedisClient redis, IEnumerable<string> subIds)
{
var keys = subIds.Map(x => RedisIndex.Subscription.Fmt(x));
var infos = redis.GetValues<SubscriptionInfo>(keys);
return infos;
}
public RedisServerEvents(IRedisClientsManager clientsManager)
: this(new RedisPubSubServer(clientsManager, Topic)) { }
Task HandleOnJoinAsync(IEventSubscription sub)
{
return NotifyChannelsAsync(sub.Channels, "cmd.onJoin", sub.Meta);
}
Task HandleOnLeaveAsync(IEventSubscription sub)
{
return NotifyChannelsAsync(sub.Channels, "cmd.onLeave", sub.Meta);
}
Task HandleOnUpdate(IEventSubscription sub)
{
using (var redis = clientsManager.GetClient())
{
StoreSubscriptionInfo(redis, sub.GetInfo());
}
return NotifyChannelsAsync(sub.Channels, "cmd.onUpdate", sub.Meta);
}
Task NotifyHeartbeatAsync(IEventSubscription sub) =>
NotifySubscriptionAsync(sub.SubscriptionId, "cmd.onHeartbeat", sub.Meta);
private void RemoveSubscriptionFromRedis(SubscriptionInfo info)
{
var id = info.SubscriptionId;
using var redis = clientsManager.GetClient();
using var trans = redis.CreateTransaction();
trans.QueueCommand(r => r.Remove(RedisIndex.Subscription.Fmt(id)));
trans.QueueCommand(r => r.RemoveItemFromSortedSet(RedisIndex.ActiveSubscriptionsSet, id));
trans.QueueCommand(r => r.RemoveItemFromSet(RedisIndex.UserIdSet.Fmt(info.UserId), id));
foreach (var channel in info.Channels)
{
trans.QueueCommand(r => r.RemoveItemFromSet(RedisIndex.ChannelSet.Fmt(channel), id));
}
if (info.UserName != null)
trans.QueueCommand(r => r.RemoveItemFromSet(RedisIndex.UserNameSet.Fmt(info.UserName), id));
if (info.SessionId != null)
trans.QueueCommand(r => r.RemoveItemFromSet(RedisIndex.SessionSet.Fmt(info.SessionId), id));
trans.Commit();
}
string HandleSerialize(object o)
{
return (string)o; //Already a serialized JSON string
}
public void NotifyAll(string selector, object message) => NotifyRedis("notify.all", selector, message);
public Task NotifyAllAsync(string selector, object message, CancellationToken token = default) => NotifyRedisAsync("notify.all", selector, message, token:token);
public Task NotifyAllJsonAsync(string selector, string json, CancellationToken token = default) => NotifyRedisRawAsync("notify.all", selector, json, token:token);
public void NotifyChannels(string[] channels, string selector, IDictionary<string, string> meta)
{
foreach (var channel in channels)
{
var msg = new Dictionary<string, string>(meta) { { "channel", channel } };
NotifyRedis("notify.channel." + channel, selector, msg);
}
}
public Task NotifyChannelsAsync(string[] channels, string selector, IDictionary<string, string> meta, CancellationToken token=default)
{
NotifyChannels(channels, selector, meta);
return TypeConstants.EmptyTask;
}
public void NotifyChannel(string channel, string selector, object message) => NotifyRedis("notify.channel." + channel, selector, message);
public Task NotifyChannelAsync(string channel, string selector, object message, CancellationToken token = default) =>
NotifyRedisAsync("notify.channel." + channel, selector, message, token: token);
public Task NotifyChannelJsonAsync(string channel, string selector, string json, CancellationToken token = default) =>
NotifyRedisRawAsync("notify.channel." + channel, selector, json, token: token);
public void NotifySubscription(string subscriptionId, string selector, object message, string channel = null) =>
NotifyRedis("notify.subscription." + subscriptionId, selector, message, channel);
public Task NotifySubscriptionAsync(string subscriptionId, string selector, object message, string channel = null, CancellationToken token = default) =>
NotifyRedisAsync("notify.subscription." + subscriptionId, selector, message, channel, token);
public Task NotifySubscriptionJsonAsync(string subscriptionId, string selector, string json, string channel = null, CancellationToken token = default) =>
NotifyRedisRawAsync("notify.subscription." + subscriptionId, selector, json, channel, token);
public void NotifyUserId(string userId, string selector, object message, string channel = null) =>
NotifyRedis("notify.userid." + userId, selector, message, channel);
public Task NotifyUserIdAsync(string userId, string selector, object message, string channel = null, CancellationToken token = default) =>
NotifyRedisAsync("notify.userid." + userId, selector, message, channel, token);
public Task NotifyUserIdJsonAsync(string userId, string selector, string json, string channel = null, CancellationToken token = default) =>
NotifyRedisRawAsync("notify.userid." + userId, selector, json, channel, token);
public void NotifyUserName(string userName, string selector, object message, string channel = null) =>
NotifyRedis("notify.username." + userName, selector, message, channel);
public Task NotifyUserNameAsync(string userName, string selector, object message, string channel = null, CancellationToken token = default) =>
NotifyRedisAsync("notify.username." + userName, selector, message, channel, token);
public Task NotifyUserNameJsonAsync(string userName, string selector, string json, string channel = null, CancellationToken token = default) =>
NotifyRedisRawAsync("notify.username." + userName, selector, json, channel, token);
public void NotifySession(string sessionId, string selector, object message, string channel = null) =>
NotifyRedis("notify.session." + sessionId, selector, message, channel);
public Task NotifySessionAsync(string sessionId, string selector, object message, string channel = null, CancellationToken token = default) =>
NotifyRedisAsync("notify.session." + sessionId, selector, message, channel, token);
public Task NotifySessionJsonAsync(string sessionId, string selector, string json, string channel = null, CancellationToken token = default) =>
NotifyRedisRawAsync("notify.session." + sessionId, selector, json, channel, token);
public SubscriptionInfo GetSubscriptionInfo(string id)
{
using var redis = clientsManager.GetClient();
var info = redis.Get<SubscriptionInfo>(RedisIndex.Subscription.Fmt(id));
return info;
}
public List<SubscriptionInfo> GetSubscriptionInfosByUserId(string userId)
{
using var redis = clientsManager.GetClient();
var ids = redis.GetAllItemsFromSet(RedisIndex.UserIdSet.Fmt(userId));
var keys = ids.Map(x => RedisIndex.Subscription.Fmt(x));
var infos = redis.GetValues<SubscriptionInfo>(keys);
return infos;
}
public async Task RegisterAsync(IEventSubscription sub, Dictionary<string, string> connectArgs = null, CancellationToken token=default)
{
if (sub == null)
throw new ArgumentNullException(nameof(sub));
var info = sub.GetInfo();
using (var redis = clientsManager.GetClient())
{
StoreSubscriptionInfo(redis, info);
}
if (connectArgs != null)
await sub.PublishAsync("cmd.onConnect", connectArgs.ToJson(), token).ConfigAwait();
await Local.RegisterAsync(sub, token: token).ConfigAwait();
}
private void StoreSubscriptionInfo(IRedisClient redis, SubscriptionInfo info)
{
var id = info.SubscriptionId;
using var trans = redis.CreateTransaction();
trans.QueueCommand(r => r.AddItemToSortedSet(RedisIndex.ActiveSubscriptionsSet, id, RedisPubSub.CurrentServerTime.Ticks));
trans.QueueCommand(r => r.Set(RedisIndex.Subscription.Fmt(id), info));
trans.QueueCommand(r => r.AddItemToSet(RedisIndex.UserIdSet.Fmt(info.UserId), id));
foreach (var channel in info.Channels)
{
trans.QueueCommand(r => r.AddItemToSet(RedisIndex.ChannelSet.Fmt(channel), id));
}
if (info.UserName != null)
trans.QueueCommand(r => r.AddItemToSet(RedisIndex.UserNameSet.Fmt(info.UserName), id));
if (info.SessionId != null)
trans.QueueCommand(r => r.AddItemToSet(RedisIndex.SessionSet.Fmt(info.SessionId), id));
trans.Commit();
}
public void UnRegister(string subscriptionId)
{
var info = GetSubscriptionInfo(subscriptionId);
if (info == null)
return;
NotifyRedis("unregister.id." + subscriptionId, null, null);
}
public Task UnRegisterAsync(string subscriptionId, CancellationToken token = default)
{
UnRegister(subscriptionId);
return TypeConstants.EmptyTask;
}
public long GetNextSequence(string sequenceId)
{
using (var redis = clientsManager.GetClient())
{
return redis.Increment("sse:seq:" + sequenceId, 1);
}
}
public int RemoveExpiredSubscriptions() => Local.RemoveExpiredSubscriptions();
public Task<int> RemoveExpiredSubscriptionsAsync(CancellationToken token=default) => Local.RemoveExpiredSubscriptionsAsync(token);
public void SubscribeToChannels(string subscriptionId, string[] channels)
{
var info = GetSubscriptionInfo(subscriptionId);
if (info == null)
return;
NotifyRedis("subscribe.id." + subscriptionId, null, channels.Join(","));
}
public Task SubscribeToChannelsAsync(string subscriptionId, string[] channels, CancellationToken token = default)
{
SubscribeToChannels(subscriptionId, channels);
return TypeConstants.EmptyTask;
}
public void UnsubscribeFromChannels(string subscriptionId, string[] channels)
{
var info = GetSubscriptionInfo(subscriptionId);
if (info == null)
return;
using (var redis = clientsManager.GetClient())
using (var trans = redis.CreateTransaction())
{
foreach (var channel in channels)
{
trans.QueueCommand(r => r.RemoveItemFromSet(RedisIndex.ChannelSet.Fmt(channel), subscriptionId));
}
trans.Commit();
}
NotifyRedis("unsubscribe.id." + subscriptionId, null, channels.Join(","));
}
public Task UnsubscribeFromChannelsAsync(string subscriptionId, string[] channels, CancellationToken token = default)
{
UnsubscribeFromChannels(subscriptionId, channels);
return TypeConstants.EmptyTask;
}
public void QueueAsyncTask(Func<Task> task) => Local.QueueAsyncTask(task);
public MemoryServerEvents GetMemoryServerEvents() => Local;
public List<Dictionary<string, string>> GetSubscriptionsDetails(params string[] channels)
{
using var redis = clientsManager.GetClient();
var ids = new HashSet<string>();
foreach (var channel in channels)
{
var channelIds = redis.GetAllItemsFromSet(RedisIndex.ChannelSet.Fmt(channel));
foreach (var channelId in channelIds)
{
ids.Add(channelId);
}
}
var keys = ids.Map(x => RedisIndex.Subscription.Fmt(x));
var infos = redis.GetValues<SubscriptionInfo>(keys);
var metas = infos.Map(x => x.Meta.ToDictionary());
return metas;
}
public List<Dictionary<string, string>> GetAllSubscriptionsDetails()
{
using var redis = clientsManager.GetClient();
var ids = new HashSet<string>();
var channelSetKeys = redis.ScanAllKeys(pattern: RedisIndex.ChannelSet.Fmt("*"));
foreach (var channelSetKey in channelSetKeys)
{
var channelIds = redis.GetAllItemsFromSet(channelSetKey);
foreach (var channelId in channelIds)
{
ids.Add(channelId);
}
}
var keys = ids.Map(x => RedisIndex.Subscription.Fmt(x));
var infos = redis.GetValues<SubscriptionInfo>(keys);
var metas = infos.Map(x => x.Meta.ToDictionary());
return metas;
}
public List<SubscriptionInfo> GetAllSubscriptionInfos()
{
using var redis = clientsManager.GetClient();
var ids = new HashSet<string>();
var channelSetKeys = redis.ScanAllKeys(pattern: RedisIndex.ChannelSet.Fmt("*"));
foreach (var channelSetKey in channelSetKeys)
{
var channelIds = redis.GetAllItemsFromSet(channelSetKey);
foreach (var channelId in channelIds)
{
ids.Add(channelId);
}
}
var keys = ids.Map(x => RedisIndex.Subscription.Fmt(x));
var infos = redis.GetValues<SubscriptionInfo>(keys);
return infos;
}
public Task<bool> PulseAsync(string subscriptionId, CancellationToken token=default)
{
using var redis = clientsManager.GetClient();
var info = redis.Get<SubscriptionInfo>(RedisIndex.Subscription.Fmt(subscriptionId));
if (info == null)
return TypeConstants.FalseTask;
redis.AddItemToSortedSet(RedisIndex.ActiveSubscriptionsSet,
info.SubscriptionId, RedisPubSub.CurrentServerTime.Ticks);
NotifyRedis("pulse.id." + subscriptionId, null, null);
return TypeConstants.TrueTask;
}
public void Reset()
{
Local.Reset();
using var redis = clientsManager.GetClient();
var keysToDelete = new List<string> { RedisIndex.ActiveSubscriptionsSet };
keysToDelete.AddRange(redis.SearchKeys(RedisIndex.Subscription.Replace("{0}", "*")));
keysToDelete.AddRange(redis.SearchKeys(RedisIndex.ChannelSet.Replace("{0}", "*")));
keysToDelete.AddRange(redis.SearchKeys(RedisIndex.UserIdSet.Replace("{0}", "*")));
keysToDelete.AddRange(redis.SearchKeys(RedisIndex.UserNameSet.Replace("{0}", "*")));
keysToDelete.AddRange(redis.SearchKeys(RedisIndex.SessionSet.Replace("{0}", "*")));
redis.RemoveAll(keysToDelete);
}
public void Start()
{
RedisPubSub.Start();
Local.Start();
}
public void Stop()
{
RedisPubSub?.Stop();
Local?.Stop();
}
public async Task StopAsync()
{
RedisPubSub?.Stop();
if (Local != null) await Local.StopAsync();
}
public Dictionary<string, string> GetStats() => Local.GetStats();
protected Task NotifyRedisAsync(string key, string selector, object message, string channel = null, CancellationToken token=default)
{
NotifyRedis(key, selector, message, channel);
return TypeConstants.EmptyTask;
}
protected Task NotifyRedisRawAsync(string key, string selector, string json, string channel = null, CancellationToken token=default)
{
NotifyRedisRaw(key, selector, json, channel);
return TypeConstants.EmptyTask;
}
protected void NotifyRedisRaw(string key, string selector, string json, string channel = null)
{
using var redis = clientsManager.GetClient();
var sb = StringBuilderCache.Allocate().Append(key);
if (selector != null)
{
sb.Append(' ').Append(selector);
if (channel != null)
{
sb.Append('@');
sb.Append(channel);
}
}
if (json != null)
{
sb.Append(' ');
sb.Append(json);
}
var msg = StringBuilderCache.ReturnAndFree(sb);
redis.PublishMessage(Topic, msg);
}
protected void NotifyRedis(string key, string selector, object message, string channel = null) =>
NotifyRedisRaw(key, selector, message?.ToJson(), channel);
public void HandleMessage(string channel, string message)
{
OnMessage(message);
}
protected void OnMessage(string message)
{
var parts = message.SplitOnFirst(' ');
var tokens = parts[0].Split('.');
var cmd = tokens[0];
switch (cmd)
{
case "notify":
var notify = tokens[1];
var who = tokens.Length > 2 ? tokens[2] : null;
var body = parts[1].SplitOnFirst(' ');
var selUri = body[0];
var selParts = selUri.SplitOnFirst('@');
var selector = selParts[0];
var channel = selParts.Length > 1 ? selParts[1] : null;
var msg = body.Length > 1 ? body[1] : null;
switch (notify)
{
case "all":
Local.NotifyAll(selector, msg);
break;
case "channel":
Local.NotifyChannel(who, selector, msg);
break;
case "subscription":
Local.NotifySubscription(who, selector, msg, channel);
break;
case "userid":
Local.NotifyUserId(who, selector, msg, channel);
break;
case "username":
Local.NotifyUserName(who, selector, msg, channel);
break;
case "session":
Local.NotifySession(who, selector, msg, channel);
break;
}
break;
case "subscribe":
if (tokens[1] == "id" && parts.Length == 2)
{
var id = tokens.Length > 2 ? tokens[2] : null;
var channelsList = parts[1].FromJson<string>();
Local.SubscribeToChannels(id, channelsList.Split(','));
}
break;
case "unsubscribe":
if (tokens[1] == "id" && parts.Length == 2)
{
var id = tokens.Length > 2 ? tokens[2] : null;
var channelsList = parts[1].FromJson<string>();
Local.UnsubscribeFromChannels(id, channelsList.Split(','));
}
break;
case "unregister":
var unregister = tokens[1];
if (unregister == "id")
{
var id = tokens.Length > 2 ? tokens[2] : null;
Local.UnRegister(id);
}
break;
case "pulse":
var pulse = tokens[1];
if (pulse == "id")
{
var id = tokens.Length > 2 ? tokens[2] : null;
Local.Pulse(id);
}
break;
}
}
public void Dispose()
{
try
{
foreach (var entry in Local.Subscriptions)
{
var info = Local.GetSubscriptionInfo(entry.Key);
if (info != null)
{
RemoveSubscriptionFromRedis(info);
}
}
}
catch (Exception ex)
{
Log.Warn("Error trying to remove local.Subscriptions during Dispose()...", ex);
}
RedisPubSub?.Dispose();
Local?.Dispose();
RedisPubSub = null;
Local = null;
}
}
}