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

Commit 16635ca

Browse files
committed
Move all non-required but useful API's into IRedisResolverExtended, which are useful to query but not required to impl
1 parent 5c1e0c3 commit 16635ca

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/ServiceStack.Redis/IRedisResolver.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23

34
namespace ServiceStack.Redis
45
{
@@ -7,13 +8,21 @@ namespace ServiceStack.Redis
78
/// </summary>
89
public interface IRedisResolver
910
{
11+
Func<RedisEndpoint, RedisClient> ClientFactory { get; set; }
12+
1013
int ReadWriteHostsCount { get; }
1114
int ReadOnlyHostsCount { get; }
1215

1316
void ResetMasters(IEnumerable<string> hosts);
1417
void ResetSlaves(IEnumerable<string> hosts);
1518

16-
RedisClient CreateRedisClient(RedisEndpoint config, bool readWrite);
19+
RedisClient CreateMasterClient(int desiredIndex);
20+
RedisClient CreateSlaveClient(int desiredIndex);
21+
}
22+
23+
public interface IRedisResolverExtended : IRedisResolver
24+
{
25+
RedisClient CreateRedisClient(RedisEndpoint config, bool master);
1726

1827
RedisEndpoint GetReadWriteHost(int desiredIndex);
1928
RedisEndpoint GetReadOnlyHost(int desiredIndex);
@@ -23,4 +32,22 @@ public interface IHasRedisResolver
2332
{
2433
IRedisResolver RedisResolver { get; set; }
2534
}
35+
36+
public static class RedisResolverExtensions
37+
{
38+
public static RedisClient CreateRedisClient(this IRedisResolver resolver, RedisEndpoint config, bool master)
39+
{
40+
return ((IRedisResolverExtended)resolver).CreateRedisClient(config, master);
41+
}
42+
43+
public static RedisEndpoint GetReadWriteHost(this IRedisResolver resolver, int desiredIndex)
44+
{
45+
return ((IRedisResolverExtended)resolver).GetReadWriteHost(desiredIndex);
46+
}
47+
48+
public static RedisEndpoint GetReadOnlyHost(this IRedisResolver resolver, int desiredIndex)
49+
{
50+
return ((IRedisResolverExtended)resolver).GetReadOnlyHost(desiredIndex);
51+
}
52+
}
2653
}

0 commit comments

Comments
 (0)