Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 33bd8a2

Browse files
committed
Move RedisPubServer to Redis project
1 parent ea579f5 commit 33bd8a2

File tree

4 files changed

+426
-1
lines changed

4 files changed

+426
-1
lines changed

src/ServiceStack.Redis/RedisClientsManagerExtensions.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,34 @@
55
namespace ServiceStack.Redis
66
{
77
/// <summary>
8-
/// Useful wrapper IRedisClientsManager to cut down the boiler plat of most IRedisClient access
8+
/// Useful wrapper IRedisClientsManager to cut down the boiler plate of most IRedisClient access
99
/// </summary>
1010
public static class RedisClientsManagerExtensions
1111
{
12+
/// <summary>
13+
/// Creates a PubSubServer that uses a background thread to listen and process for
14+
/// Redis Pub/Sub messages published to the specified channel.
15+
/// Use optional callbacks to listen for message, error and life-cycle events.
16+
/// Callbacks can be assigned later, then call Start() for PubSubServer to start listening for messages
17+
/// </summary>
18+
public static IRedisPubSubServer CreatePubSubServer(this IRedisClientsManager redisManager,
19+
string channel,
20+
Action<string, string> onMessage = null,
21+
Action<Exception> onError = null,
22+
Action onInit = null,
23+
Action onStart = null,
24+
Action onStop = null)
25+
{
26+
return new RedisPubSubServer(redisManager, channel)
27+
{
28+
OnMessage = onMessage,
29+
OnError = onError,
30+
OnInit = onInit,
31+
OnStart = onStart,
32+
OnStop = onStop,
33+
};
34+
}
35+
1236
public static void Exec(this IRedisClientsManager redisManager, Action<IRedisClient> lambda)
1337
{
1438
using (var redis = redisManager.GetClient())

0 commit comments

Comments
 (0)