Commit 0acb02ab authored by Nick Craver's avatar Nick Craver

Cleanup: DebuggingAids

parent f74d650c
...@@ -19,11 +19,15 @@ public partial interface IServer ...@@ -19,11 +19,15 @@ public partial interface IServer
/// <summary> /// <summary>
/// Show what is in the pending (unsent) queue /// Show what is in the pending (unsent) queue
/// </summary> /// </summary>
/// <param name="maxCount">The maximum count to list.</param>
string ListPending(int maxCount); string ListPending(int maxCount);
/// <summary> /// <summary>
/// Get the value of key. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GET only handles string values. /// Get the value of key. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GET only handles string values.
/// </summary> /// </summary>
/// <param name="db">The database to get <paramref name="key"/> from.</param>
/// <param name="key">The key to get.</param>
/// <param name="flags">The command flags to use.</param>
/// <returns>the value of key, or nil when key does not exist.</returns> /// <returns>the value of key, or nil when key does not exist.</returns>
/// <remarks>https://redis.io/commands/get</remarks> /// <remarks>https://redis.io/commands/get</remarks>
RedisValue StringGet(int db, RedisKey key, CommandFlags flags = CommandFlags.None); RedisValue StringGet(int db, RedisKey key, CommandFlags flags = CommandFlags.None);
...@@ -31,6 +35,9 @@ public partial interface IServer ...@@ -31,6 +35,9 @@ public partial interface IServer
/// <summary> /// <summary>
/// Get the value of key. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GET only handles string values. /// Get the value of key. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GET only handles string values.
/// </summary> /// </summary>
/// <param name="db">The database to get <paramref name="key"/> from.</param>
/// <param name="key">The key to get.</param>
/// <param name="flags">The command flags to use.</param>
/// <returns>the value of key, or nil when key does not exist.</returns> /// <returns>the value of key, or nil when key does not exist.</returns>
/// <remarks>https://redis.io/commands/get</remarks> /// <remarks>https://redis.io/commands/get</remarks>
Task<RedisValue> StringGetAsync(int db, RedisKey key, CommandFlags flags = CommandFlags.None); Task<RedisValue> StringGetAsync(int db, RedisKey key, CommandFlags flags = CommandFlags.None);
...@@ -49,6 +56,8 @@ public partial interface IServer ...@@ -49,6 +56,8 @@ public partial interface IServer
/// <summary> /// <summary>
/// CLIENT PAUSE is a connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds). /// CLIENT PAUSE is a connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds).
/// </summary> /// </summary>
/// <param name="duration">The time span to hang for.</param>
/// <param name="flags">The command flags to use.</param>
/// <remarks>https://redis.io/commands/client-pause</remarks> /// <remarks>https://redis.io/commands/client-pause</remarks>
void Hang(TimeSpan duration, CommandFlags flags = CommandFlags.None); void Hang(TimeSpan duration, CommandFlags flags = CommandFlags.None);
} }
...@@ -58,6 +67,7 @@ public partial interface IRedis ...@@ -58,6 +67,7 @@ public partial interface IRedis
/// <summary> /// <summary>
/// The CLIENT GETNAME returns the name of the current connection as set by CLIENT SETNAME. Since every new connection starts without an associated name, if no name was assigned a null string is returned. /// The CLIENT GETNAME returns the name of the current connection as set by CLIENT SETNAME. Since every new connection starts without an associated name, if no name was assigned a null string is returned.
/// </summary> /// </summary>
/// <param name="flags">The command flags to use.</param>
/// <remarks>https://redis.io/commands/client-getname</remarks> /// <remarks>https://redis.io/commands/client-getname</remarks>
/// <returns>The connection name, or a null string if no name is set.</returns> /// <returns>The connection name, or a null string if no name is set.</returns>
string ClientGetName(CommandFlags flags = CommandFlags.None); string ClientGetName(CommandFlags flags = CommandFlags.None);
...@@ -65,6 +75,7 @@ public partial interface IRedis ...@@ -65,6 +75,7 @@ public partial interface IRedis
/// <summary> /// <summary>
/// Ask the server to close the connection. The connection is closed as soon as all pending replies have been written to the client. /// Ask the server to close the connection. The connection is closed as soon as all pending replies have been written to the client.
/// </summary> /// </summary>
/// <param name="flags">The command flags to use.</param>
/// <remarks>https://redis.io/commands/quit</remarks> /// <remarks>https://redis.io/commands/quit</remarks>
void Quit(CommandFlags flags = CommandFlags.None); void Quit(CommandFlags flags = CommandFlags.None);
} }
...@@ -74,6 +85,7 @@ public partial interface IRedisAsync ...@@ -74,6 +85,7 @@ public partial interface IRedisAsync
/// <summary> /// <summary>
/// The CLIENT GETNAME returns the name of the current connection as set by CLIENT SETNAME. Since every new connection starts without an associated name, if no name was assigned a null string is returned. /// The CLIENT GETNAME returns the name of the current connection as set by CLIENT SETNAME. Since every new connection starts without an associated name, if no name was assigned a null string is returned.
/// </summary> /// </summary>
/// <param name="flags">The command flags to use.</param>
/// <remarks>https://redis.io/commands/client-getname</remarks> /// <remarks>https://redis.io/commands/client-getname</remarks>
/// <returns>The connection name, or a null string if no name is set.</returns> /// <returns>The connection name, or a null string if no name is set.</returns>
Task<string> ClientGetNameAsync(CommandFlags flags = CommandFlags.None); Task<string> ClientGetNameAsync(CommandFlags flags = CommandFlags.None);
...@@ -138,14 +150,11 @@ internal partial class CompletionManager ...@@ -138,14 +150,11 @@ internal partial class CompletionManager
{ {
private static long asyncCompletionWorkerCount; private static long asyncCompletionWorkerCount;
partial void OnCompletedAsync() #pragma warning disable RCS1047 // Non-asynchronous method name should not end with 'Async'.
{ partial void OnCompletedAsync() => Interlocked.Increment(ref asyncCompletionWorkerCount);
Interlocked.Increment(ref asyncCompletionWorkerCount); #pragma warning restore RCS1047 // Non-asynchronous method name should not end with 'Async'.
}
internal static long GetAsyncCompletionWorkerCount() internal static long GetAsyncCompletionWorkerCount() => Interlocked.Read(ref asyncCompletionWorkerCount);
{
return Interlocked.Read(ref asyncCompletionWorkerCount);
}
} }
public partial class ConnectionMultiplexer public partial class ConnectionMultiplexer
...@@ -153,22 +162,20 @@ public partial class ConnectionMultiplexer ...@@ -153,22 +162,20 @@ public partial class ConnectionMultiplexer
/// <summary> /// <summary>
/// Gets how many result-box instances were allocated /// Gets how many result-box instances were allocated
/// </summary> /// </summary>
public static long GetResultBoxAllocationCount() public static long GetResultBoxAllocationCount() => ResultBox.GetAllocationCount();
{
return ResultBox.GetAllocationCount();
}
/// <summary> /// <summary>
/// Gets how many async completion workers were queueud /// Gets how many async completion workers were queueud
/// </summary> /// </summary>
public static long GetAsyncCompletionWorkerCount() public static long GetAsyncCompletionWorkerCount() => CompletionManager.GetAsyncCompletionWorkerCount();
{
return CompletionManager.GetAsyncCompletionWorkerCount(); private volatile bool allowConnect = true,
} ignoreConnect = false;
/// <summary> /// <summary>
/// For debugging; when not enabled, servers cannot connect /// For debugging; when not enabled, servers cannot connect
/// </summary> /// </summary>
public bool AllowConnect { get { return allowConnect; } set { allowConnect = value; } } public bool AllowConnect { get { return allowConnect; } set { allowConnect = value; } }
private volatile bool allowConnect = true, ignoreConnect = false;
/// <summary> /// <summary>
/// For debugging; when not enabled, end-connect is silently ignored (to simulate a long-running connect) /// For debugging; when not enabled, end-connect is silently ignored (to simulate a long-running connect)
...@@ -341,7 +348,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin ...@@ -341,7 +348,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin
AsyncCallback proxyCallback; AsyncCallback proxyCallback;
if (completionType == CompletionType.Any) if (completionType == CompletionType.Any)
{ {
proxyCallback = (ar) => proxyCallback = ar =>
{ {
if (!ar.CompletedSynchronously) if (!ar.CompletedSynchronously)
{ {
...@@ -351,7 +358,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin ...@@ -351,7 +358,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin
} }
else else
{ {
proxyCallback = (ar) => { }; proxyCallback = _ => { };
} }
var result = beginAsync(proxyCallback); var result = beginAsync(proxyCallback);
...@@ -366,7 +373,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin ...@@ -366,7 +373,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin
switch (completionType) switch (completionType)
{ {
case CompletionType.Async: case CompletionType.Async:
ThreadPool.QueueUserWorkItem((s) => callback(result)); ThreadPool.QueueUserWorkItem(_ => callback(result));
break; break;
case CompletionType.Any: case CompletionType.Any:
case CompletionType.Sync: case CompletionType.Sync:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment