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
1305424b
Commit
1305424b
authored
Sep 12, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include libver in exceptions, because I'm tired of asking for it
parent
b963ec8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
18 deletions
+35
-18
ExceptionFactory.cs
src/StackExchange.Redis/ExceptionFactory.cs
+15
-3
PhysicalConnection.cs
src/StackExchange.Redis/PhysicalConnection.cs
+7
-6
RedisValue.cs
src/StackExchange.Redis/RedisValue.cs
+6
-9
ExceptionFactoryTests.cs
tests/StackExchange.Redis.Tests/ExceptionFactoryTests.cs
+7
-0
No files found.
src/StackExchange.Redis/ExceptionFactory.cs
View file @
1305424b
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Reflection
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading
;
...
@@ -146,7 +147,7 @@ internal static Exception PopulateInnerExceptions(ReadOnlySpan<ServerEndPoint> s
...
@@ -146,7 +147,7 @@ internal static Exception PopulateInnerExceptions(ReadOnlySpan<ServerEndPoint> s
{
{
return
innerExceptions
[
0
];
return
innerExceptions
[
0
];
}
}
else
if
(
innerExceptions
.
Count
>
1
)
else
if
(
innerExceptions
.
Count
>
1
)
{
{
return
new
AggregateException
(
innerExceptions
);
return
new
AggregateException
(
innerExceptions
);
}
}
...
@@ -167,6 +168,17 @@ internal static Exception NoCursor(RedisCommand command)
...
@@ -167,6 +168,17 @@ internal static Exception NoCursor(RedisCommand command)
return
new
RedisCommandException
(
"Command cannot be used with a cursor: "
+
s
);
return
new
RedisCommandException
(
"Command cannot be used with a cursor: "
+
s
);
}
}
private
static
string
_libVersion
;
internal
static
string
GetLibVersion
()
{
if
(
_libVersion
==
null
)
{
var
assembly
=
typeof
(
ConnectionMultiplexer
).
Assembly
;
_libVersion
=
((
AssemblyFileVersionAttribute
)
Attribute
.
GetCustomAttribute
(
assembly
,
typeof
(
AssemblyFileVersionAttribute
)))?.
Version
??
assembly
.
GetName
().
Version
.
ToString
();
}
return
_libVersion
;
}
internal
static
Exception
Timeout
(
ConnectionMultiplexer
mutiplexer
,
string
baseErrorMessage
,
Message
message
,
ServerEndPoint
server
)
internal
static
Exception
Timeout
(
ConnectionMultiplexer
mutiplexer
,
string
baseErrorMessage
,
Message
message
,
ServerEndPoint
server
)
{
{
List
<
Tuple
<
string
,
string
>>
data
=
new
List
<
Tuple
<
string
,
string
>>
{
Tuple
.
Create
(
"Message"
,
message
.
CommandAndKey
)
};
List
<
Tuple
<
string
,
string
>>
data
=
new
List
<
Tuple
<
string
,
string
>>
{
Tuple
.
Create
(
"Message"
,
message
.
CommandAndKey
)
};
...
@@ -188,13 +200,13 @@ void add(string lk, string sk, string v)
...
@@ -188,13 +200,13 @@ void add(string lk, string sk, string v)
sb
.
Append
(
", "
).
Append
(
sk
).
Append
(
": "
).
Append
(
v
);
sb
.
Append
(
", "
).
Append
(
sk
).
Append
(
": "
).
Append
(
v
);
}
}
}
}
add
(
"Version"
,
"v"
,
GetLibVersion
());
if
(
server
!=
null
)
if
(
server
!=
null
)
{
{
server
.
GetOutstandingCount
(
message
.
Command
,
out
int
inst
,
out
int
qs
,
out
int
@in
);
server
.
GetOutstandingCount
(
message
.
Command
,
out
int
inst
,
out
int
qs
,
out
int
@in
);
add
(
"Instantaneous"
,
"inst"
,
inst
.
ToString
());
add
(
"Instantaneous"
,
"inst"
,
inst
.
ToString
());
add
(
"Queue-Awaiting-Response"
,
"qs"
,
qs
.
ToString
());
add
(
"Queue-Awaiting-Response"
,
"qs"
,
qs
.
ToString
());
add
(
"Inbound-Bytes"
,
"in"
,
@in
.
ToString
());
if
(
@in
>=
0
)
add
(
"Inbound-Bytes"
,
"in"
,
@in
.
ToString
());
if
(
mutiplexer
.
StormLogThreshold
>=
0
&&
qs
>=
mutiplexer
.
StormLogThreshold
&&
Interlocked
.
CompareExchange
(
ref
mutiplexer
.
haveStormLog
,
1
,
0
)
==
0
)
if
(
mutiplexer
.
StormLogThreshold
>=
0
&&
qs
>=
mutiplexer
.
StormLogThreshold
&&
Interlocked
.
CompareExchange
(
ref
mutiplexer
.
haveStormLog
,
1
,
0
)
==
0
)
{
{
...
...
src/StackExchange.Redis/PhysicalConnection.cs
View file @
1305424b
...
@@ -328,6 +328,13 @@ public Task FlushAsync()
...
@@ -328,6 +328,13 @@ public Task FlushAsync()
}
}
var
data
=
new
List
<
Tuple
<
string
,
string
>>();
var
data
=
new
List
<
Tuple
<
string
,
string
>>();
void
add
(
string
lk
,
string
sk
,
string
v
)
{
data
.
Add
(
Tuple
.
Create
(
lk
,
v
));
exMessage
.
Append
(
", "
).
Append
(
sk
).
Append
(
": "
).
Append
(
v
);
}
add
(
"Version"
,
"v"
,
ExceptionFactory
.
GetLibVersion
());
if
(
IncludeDetailInExceptions
)
if
(
IncludeDetailInExceptions
)
{
{
if
(
bridge
!=
null
)
if
(
bridge
!=
null
)
...
@@ -339,12 +346,6 @@ public Task FlushAsync()
...
@@ -339,12 +346,6 @@ public Task FlushAsync()
data
.
Add
(
Tuple
.
Create
(
"FailureType"
,
failureType
.
ToString
()));
data
.
Add
(
Tuple
.
Create
(
"FailureType"
,
failureType
.
ToString
()));
data
.
Add
(
Tuple
.
Create
(
"EndPoint"
,
Format
.
ToString
(
bridge
.
ServerEndPoint
?.
EndPoint
)));
data
.
Add
(
Tuple
.
Create
(
"EndPoint"
,
Format
.
ToString
(
bridge
.
ServerEndPoint
?.
EndPoint
)));
void
add
(
string
lk
,
string
sk
,
string
v
)
{
data
.
Add
(
Tuple
.
Create
(
lk
,
v
));
exMessage
.
Append
(
", "
).
Append
(
sk
).
Append
(
": "
).
Append
(
v
);
}
add
(
"Origin"
,
"origin"
,
origin
);
add
(
"Origin"
,
"origin"
,
origin
);
// add("Input-Buffer", "input-buffer", _ioPipe.Input);
// add("Input-Buffer", "input-buffer", _ioPipe.Input);
add
(
"Outstanding-Responses"
,
"outstanding"
,
GetSentAwaitingResponseCount
().
ToString
());
add
(
"Outstanding-Responses"
,
"outstanding"
,
GetSentAwaitingResponseCount
().
ToString
());
...
...
src/StackExchange.Redis/RedisValue.cs
View file @
1305424b
...
@@ -799,9 +799,8 @@ private RedisValue Simplify()
...
@@ -799,9 +799,8 @@ private RedisValue Simplify()
}
}
/// <summary>
/// <summary>
/// Convert to a long if possible, returning true.
/// <para>Convert to a long if possible, returning true.</para>
///
/// <para>Returns false otherwise.</para>
/// Returns false otherwise.
/// </summary>
/// </summary>
/// <param name="val">The <see cref="long"/> value, if conversion was possible.</param>
/// <param name="val">The <see cref="long"/> value, if conversion was possible.</param>
public
bool
TryParse
(
out
long
val
)
public
bool
TryParse
(
out
long
val
)
...
@@ -830,9 +829,8 @@ public bool TryParse(out long val)
...
@@ -830,9 +829,8 @@ public bool TryParse(out long val)
}
}
/// <summary>
/// <summary>
/// Convert to a int if possible, returning true.
/// <para>Convert to a int if possible, returning true.</para>
///
/// <para>Returns false otherwise.</para>
/// Returns false otherwise.
/// </summary>
/// </summary>
/// <param name="val">The <see cref="int"/> value, if conversion was possible.</param>
/// <param name="val">The <see cref="int"/> value, if conversion was possible.</param>
public
bool
TryParse
(
out
int
val
)
public
bool
TryParse
(
out
int
val
)
...
@@ -848,9 +846,8 @@ public bool TryParse(out int val)
...
@@ -848,9 +846,8 @@ public bool TryParse(out int val)
}
}
/// <summary>
/// <summary>
/// Convert to a double if possible, returning true.
/// <para>Convert to a double if possible, returning true.</para>
///
/// <para>Returns false otherwise.</para>
/// Returns false otherwise.
/// </summary>
/// </summary>
/// <param name="val">The <see cref="double"/> value, if conversion was possible.</param>
/// <param name="val">The <see cref="double"/> value, if conversion was possible.</param>
public
bool
TryParse
(
out
double
val
)
public
bool
TryParse
(
out
double
val
)
...
...
tests/StackExchange.Redis.Tests/ExceptionFactoryTests.cs
View file @
1305424b
...
@@ -21,6 +21,13 @@ public void NullLastException()
...
@@ -21,6 +21,13 @@ public void NullLastException()
}
}
}
}
[
Fact
]
public
void
CanGetVersion
()
{
var
libVer
=
ExceptionFactory
.
GetLibVersion
();
Assert
.
Matches
(
@"2\.[0-9]+\.[0-9]+\.[0-9]+"
,
libVer
);
}
[
Fact
]
[
Fact
]
public
void
NullSnapshot
()
public
void
NullSnapshot
()
{
{
...
...
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