Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
267bce16
Commit
267bce16
authored
Jan 18, 2016
by
Marc Gravell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #306 from JonCole/master
Set AbortConnectOnFailure to false for Azure
parents
33072cb8
cf91c206
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
1 deletion
+76
-1
Config.cs
MigratedBookSleeveTestSuite/Config.cs
+43
-0
ConfigurationOptions.cs
...xchange.Redis/StackExchange/Redis/ConfigurationOptions.cs
+33
-1
No files found.
MigratedBookSleeveTestSuite/Config.cs
View file @
267bce16
...
...
@@ -176,6 +176,49 @@ public void CreateDisconnectedNonsenseConnection_DNS()
}
}
[
Test
]
public
void
AbortConnectFalseForAzure
()
{
var
options
=
ConfigurationOptions
.
Parse
(
"contoso.redis.cache.windows.net"
);
Assert
.
IsFalse
(
options
.
AbortOnConnectFail
);
}
[
Test
]
public
void
AbortConnectTrueForAzureWhenSpecified
()
{
var
options
=
ConfigurationOptions
.
Parse
(
"contoso.redis.cache.windows.net,abortConnect=true"
);
Assert
.
IsTrue
(
options
.
AbortOnConnectFail
);
}
[
Test
]
public
void
AbortConnectFalseForAzureChina
()
{
// added a few upper case chars to validate comparison
var
options
=
ConfigurationOptions
.
Parse
(
"contoso.REDIS.CACHE.chinacloudapi.cn"
);
Assert
.
IsFalse
(
options
.
AbortOnConnectFail
);
}
[
Test
]
public
void
AbortConnectFalseForAzureUSGov
()
{
var
options
=
ConfigurationOptions
.
Parse
(
"contoso.redis.cache.usgovcloudapi.net"
);
Assert
.
IsFalse
(
options
.
AbortOnConnectFail
);
}
[
Test
]
public
void
AbortConnectTrueForNonAzure
()
{
var
options
=
ConfigurationOptions
.
Parse
(
"redis.contoso.com"
);
Assert
.
IsTrue
(
options
.
AbortOnConnectFail
);
}
[
Test
]
public
void
AbortConnectDefaultWhenNoEndpointsSpecifiedYet
()
{
var
options
=
new
ConfigurationOptions
();
Assert
.
IsTrue
(
options
.
AbortOnConnectFail
);
}
internal
static
void
AssertNearlyEqual
(
double
x
,
double
y
)
{
if
(
Math
.
Abs
(
x
-
y
)
>
0.00001
)
Assert
.
AreEqual
(
x
,
y
);
...
...
StackExchange.Redis/StackExchange/Redis/ConfigurationOptions.cs
View file @
267bce16
...
...
@@ -129,7 +129,7 @@ public static string TryNormalize(string value)
/// <summary>
/// Gets or sets whether connect/configuration timeouts should be explicitly notified via a TimeoutException
/// </summary>
public
bool
AbortOnConnectFail
{
get
{
return
abortOnConnectFail
??
true
;
}
set
{
abortOnConnectFail
=
value
;
}
}
public
bool
AbortOnConnectFail
{
get
{
return
abortOnConnectFail
??
GetDefaultAbortOnConnectFailSetting
()
;
}
set
{
abortOnConnectFail
=
value
;
}
}
/// <summary>
/// Indicates whether admin operations should be allowed
...
...
@@ -609,6 +609,38 @@ private void DoParse(string configuration, bool ignoreUnknown)
}
}
private
bool
GetDefaultAbortOnConnectFailSetting
()
{
// Microsoft Azure team wants abortConnect=false by default
if
(
IsAzureEndpoint
())
return
false
;
return
true
;
}
private
bool
IsAzureEndpoint
()
{
var
result
=
false
;
var
dnsEndpoints
=
endpoints
.
Select
(
endpoint
=>
endpoint
as
DnsEndPoint
).
Where
(
ep
=>
ep
!=
null
);
foreach
(
var
ep
in
dnsEndpoints
)
{
int
firstDot
=
ep
.
Host
.
IndexOf
(
'.'
);
if
(
firstDot
>=
0
)
{
var
domain
=
ep
.
Host
.
Substring
(
firstDot
).
ToLowerInvariant
();
switch
(
domain
)
{
case
".redis.cache.windows.net"
:
case
".redis.cache.chinacloudapi.cn"
:
case
".redis.cache.usgovcloudapi.net"
:
return
true
;
}
}
}
return
result
;
}
private
string
InferSslHostFromEndpoints
()
{
var
dnsEndpoints
=
endpoints
.
Select
(
endpoint
=>
endpoint
as
DnsEndPoint
);
string
dnsHost
=
dnsEndpoints
.
First
()
!=
null
?
dnsEndpoints
.
First
().
Host
:
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment