This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-9
lines changed
tests/ServiceStack.Redis.Tests Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,18 @@ public IRedisClientsManager Setup()
49
49
return this . redisManager ;
50
50
}
51
51
52
+ public Func < string , string > HostFilter { get ; set ; }
53
+
54
+ internal string [ ] ConfigureHosts ( IEnumerable < string > hosts )
55
+ {
56
+ if ( hosts == null )
57
+ return new string [ 0 ] ;
58
+
59
+ return HostFilter == null
60
+ ? hosts . ToArray ( )
61
+ : hosts . Map ( HostFilter ) . ToArray ( ) ;
62
+ }
63
+
52
64
private void GetValidSentinel ( )
53
65
{
54
66
while ( this . redisManager == null && ShouldRetry ( ) )
Original file line number Diff line number Diff line change @@ -82,11 +82,15 @@ private void ConfigureRedisFromSentinel()
82
82
83
83
if ( redisManager == null )
84
84
{
85
- redisManager = redisSentinel . RedisManagerFactory . Create ( masters , slaves ) ;
85
+ redisManager = redisSentinel . RedisManagerFactory . Create (
86
+ redisSentinel . ConfigureHosts ( masters ) ,
87
+ redisSentinel . ConfigureHosts ( slaves ) ) ;
86
88
}
87
89
else
88
90
{
89
- ( ( IRedisFailover ) redisManager ) . FailoverTo ( masters , slaves ) ;
91
+ ( ( IRedisFailover ) redisManager ) . FailoverTo (
92
+ redisSentinel . ConfigureHosts ( masters ) ,
93
+ redisSentinel . ConfigureHosts ( slaves ) ) ;
90
94
}
91
95
}
92
96
Original file line number Diff line number Diff line change @@ -101,13 +101,9 @@ public void Can_specify_Timeout_on_RedisManager()
101
101
[ Test ]
102
102
public void Can_specify_db_on_RedisSentinel ( )
103
103
{
104
- var host = new [ ] { "{0}:{1}" . Fmt ( TestConfig . SentinelHost , TestConfig . RedisSentinelPort ) } ;
105
- var sentinel = new RedisSentinel ( host , TestConfig . MasterName ) {
106
- RedisManagerFactory =
107
- {
108
- FactoryFn = ( writeHosts , readHosts ) =>
109
- new PooledRedisClientManager ( writeHosts , readHosts , initalDb : 1 )
110
- }
104
+ var sentinelHosts = new [ ] { "{0}:{1}" . Fmt ( TestConfig . SentinelHost , TestConfig . RedisSentinelPort ) } ;
105
+ var sentinel = new RedisSentinel ( sentinelHosts , TestConfig . MasterName ) {
106
+ HostFilter = host => "{0}?db=1" . Fmt ( host )
111
107
} ;
112
108
113
109
using ( var clientsManager = sentinel . Setup ( ) )
You can’t perform that action at this time.
0 commit comments