Skip to content

Commit 6638b02

Browse files
committed
RESP3
1 parent f500cc9 commit 6638b02

4 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/StackExchange.Redis/PhysicalConnection.Read.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ private void OnResponseFrame(RespPrefix prefix, ReadOnlySpan<byte> frame, ref by
309309
// out-of-band; pub/sub etc
310310
if (OnOutOfBand(frame, ref lease))
311311
{
312+
OnDetailLog($"out-of-band message, not dequeuing: {prefix}");
312313
return;
313314
}
314315
break;

src/StackExchange.Redis/RespReaderExtensions.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ public RedisValue ReadRedisValue()
2222
};
2323
}
2424

25+
public string DebugReadTruncatedString(int maxChars)
26+
{
27+
if (!reader.IsScalar) return "";
28+
try
29+
{
30+
var s = reader.ReadString() ?? "";
31+
return s.Length <= maxChars ? s : s.Substring(0, maxChars) + "...";
32+
}
33+
catch
34+
{
35+
return "";
36+
}
37+
}
38+
2539
public RedisKey ReadRedisKey()
2640
{
2741
reader.DemandScalar();
@@ -30,12 +44,18 @@ public RedisKey ReadRedisKey()
3044

3145
public string GetOverview()
3246
{
47+
if (reader.Prefix is RespPrefix.None)
48+
{
49+
var copy = reader;
50+
copy.MovePastBof();
51+
return copy.Prefix is RespPrefix.None ? "(empty)" : copy.GetOverview();
52+
}
3353
if (reader.IsNull) return "(null)";
3454

3555
return reader.Prefix switch
3656
{
3757
RespPrefix.SimpleString or RespPrefix.Integer or RespPrefix.SimpleError or RespPrefix.Double => $"{reader.Prefix}: {reader.ReadString()}",
38-
_ when reader.IsScalar => $"{reader.Prefix}: {reader.ScalarLength()} bytes",
58+
_ when reader.IsScalar => $"{reader.Prefix}: {reader.ScalarLength()} bytes, '{reader.DebugReadTruncatedString(16)}'",
3959
_ when reader.IsAggregate => $"{reader.Prefix}: {reader.AggregateLength()} items",
4060
_ => $"(unknown: {reader.Prefix})",
4161
};

src/StackExchange.Redis/ResultProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ public static void SetException(Message? message, Exception ex)
224224
// true if ready to be completed (i.e. false if re-issued to another server)
225225
public virtual bool SetResult(PhysicalConnection connection, Message message, ref RespReader reader)
226226
{
227-
connection.OnDetailLog($"(core result for {message.Command}, {reader.GetFirstPrefix()})");
228227
reader.MovePastBof();
228+
connection.OnDetailLog($"(core result for {message.Command}, '{reader.GetOverview()}')");
229229
var bridge = connection.BridgeCouldBeNull;
230230
if (message is LoggingMessage logging)
231231
{

tests/StackExchange.Redis.Tests/BasicOpTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace StackExchange.Redis.Tests;
88

9+
[RunPerProtocol]
910
public class BasicOpsTests(ITestOutputHelper output, SharedConnectionFixture fixture) : TestBase(output, fixture)
1011
{
1112
[Fact]

0 commit comments

Comments
 (0)