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

Cleanup: DebuggingAids

parent f74d650c
......@@ -19,11 +19,15 @@ public partial interface IServer
/// <summary>
/// Show what is in the pending (unsent) queue
/// </summary>
/// <param name="maxCount">The maximum count to list.</param>
string ListPending(int maxCount);
/// <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.
/// </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>
/// <remarks>https://redis.io/commands/get</remarks>
RedisValue StringGet(int db, RedisKey key, CommandFlags flags = CommandFlags.None);
......@@ -31,6 +35,9 @@ public partial interface IServer
/// <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.
/// </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>
/// <remarks>https://redis.io/commands/get</remarks>
Task<RedisValue> StringGetAsync(int db, RedisKey key, CommandFlags flags = CommandFlags.None);
......@@ -49,6 +56,8 @@ public partial interface IServer
/// <summary>
/// CLIENT PAUSE is a connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds).
/// </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>
void Hang(TimeSpan duration, CommandFlags flags = CommandFlags.None);
}
......@@ -58,6 +67,7 @@ public partial interface IRedis
/// <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.
/// </summary>
/// <param name="flags">The command flags to use.</param>
/// <remarks>https://redis.io/commands/client-getname</remarks>
/// <returns>The connection name, or a null string if no name is set.</returns>
string ClientGetName(CommandFlags flags = CommandFlags.None);
......@@ -65,6 +75,7 @@ public partial interface IRedis
/// <summary>
/// Ask the server to close the connection. The connection is closed as soon as all pending replies have been written to the client.
/// </summary>
/// <param name="flags">The command flags to use.</param>
/// <remarks>https://redis.io/commands/quit</remarks>
void Quit(CommandFlags flags = CommandFlags.None);
}
......@@ -74,6 +85,7 @@ public partial interface IRedisAsync
/// <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.
/// </summary>
/// <param name="flags">The command flags to use.</param>
/// <remarks>https://redis.io/commands/client-getname</remarks>
/// <returns>The connection name, or a null string if no name is set.</returns>
Task<string> ClientGetNameAsync(CommandFlags flags = CommandFlags.None);
......@@ -138,14 +150,11 @@ internal partial class CompletionManager
{
private static long asyncCompletionWorkerCount;
partial void OnCompletedAsync()
{
Interlocked.Increment(ref asyncCompletionWorkerCount);
}
internal static long GetAsyncCompletionWorkerCount()
{
return Interlocked.Read(ref asyncCompletionWorkerCount);
}
#pragma warning disable RCS1047 // Non-asynchronous method name should not end with 'Async'.
partial void OnCompletedAsync() => Interlocked.Increment(ref asyncCompletionWorkerCount);
#pragma warning restore RCS1047 // Non-asynchronous method name should not end with 'Async'.
internal static long GetAsyncCompletionWorkerCount() => Interlocked.Read(ref asyncCompletionWorkerCount);
}
public partial class ConnectionMultiplexer
......@@ -153,22 +162,20 @@ public partial class ConnectionMultiplexer
/// <summary>
/// Gets how many result-box instances were allocated
/// </summary>
public static long GetResultBoxAllocationCount()
{
return ResultBox.GetAllocationCount();
}
public static long GetResultBoxAllocationCount() => ResultBox.GetAllocationCount();
/// <summary>
/// Gets how many async completion workers were queueud
/// </summary>
public static long GetAsyncCompletionWorkerCount()
{
return CompletionManager.GetAsyncCompletionWorkerCount();
}
public static long GetAsyncCompletionWorkerCount() => CompletionManager.GetAsyncCompletionWorkerCount();
private volatile bool allowConnect = true,
ignoreConnect = false;
/// <summary>
/// For debugging; when not enabled, servers cannot connect
/// </summary>
public bool AllowConnect { get { return allowConnect; } set { allowConnect = value; } }
private volatile bool allowConnect = true, ignoreConnect = false;
/// <summary>
/// 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
AsyncCallback proxyCallback;
if (completionType == CompletionType.Any)
{
proxyCallback = (ar) =>
proxyCallback = ar =>
{
if (!ar.CompletedSynchronously)
{
......@@ -351,7 +358,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin
}
else
{
proxyCallback = (ar) => { };
proxyCallback = _ => { };
}
var result = beginAsync(proxyCallback);
......@@ -366,7 +373,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin
switch (completionType)
{
case CompletionType.Async:
ThreadPool.QueueUserWorkItem((s) => callback(result));
ThreadPool.QueueUserWorkItem(_ => callback(result));
break;
case CompletionType.Any:
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