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

Cleanup: Interfaces

Still a lot of docs work to follow-up with here.
parent 1a25068a
namespace StackExchange.Redis
{
/// <summary>
/// If an IProfiledCommand is a retransmission of a previous command, this enum
/// is used to indicate what prompted the retransmission.
///
/// This can be used to distinguish between transient causes (moving hashslots, joining nodes, etc.)
/// and incorrect routing.
/// </summary>
public enum RetransmissionReasonType
{
/// <summary>
/// No stated reason
/// </summary>
None = 0,
/// <summary>
/// Issued to investigate which node owns a key
/// </summary>
Ask,
/// <summary>
/// A node has indicated that it does *not* own the given key
/// </summary>
Moved
}
}
......@@ -2,7 +2,7 @@
namespace StackExchange.Redis
{
interface ICompletable
internal interface ICompletable
{
void AppendStormLog(StringBuilder sb);
......
......@@ -10,7 +10,6 @@ namespace StackExchange.Redis
/// </summary>
public interface IConnectionMultiplexer
{
#if DEBUG
/// <summary>
/// For debugging; when not enabled, servers cannot connect
......
using System;
using System.Net;
namespace StackExchange.Redis
{
/// <summary>
/// If an IProfiledCommand is a retransmission of a previous command, this enum
/// is used to indicate what prompted the retransmission.
///
/// This can be used to distinguish between transient causes (moving hashslots, joining nodes, etc.)
/// and incorrect routing.
/// </summary>
public enum RetransmissionReasonType
{
/// <summary>
/// No stated reason
/// </summary>
None = 0,
/// <summary>
/// Issued to investigate which node owns a key
/// </summary>
Ask,
/// <summary>
/// A node has indicated that it does *not* own the given key
/// </summary>
Moved
}
/// <summary>
/// A profiled command against a redis instance.
///
/// TimeSpans returned by this interface use a high precision timer if possible.
/// DateTimes returned by this interface are no more precise than DateTime.UtcNow.
/// </summary>
public interface IProfiledCommand
{
/// <summary>
/// The endpoint this command was sent to.
/// </summary>
EndPoint EndPoint { get; }
/// <summary>
/// The Db this command was sent to.
/// </summary>
int Db { get; }
/// <summary>
/// The name of this command.
/// </summary>
string Command { get; }
/// <summary>
/// The CommandFlags the command was submitted with.
/// </summary>
CommandFlags Flags { get; }
/// <summary>
/// When this command was *created*, will be approximately
/// when the paired method of StackExchange.Redis was called but
/// before that method returned.
///
/// Note that the resolution of the returned DateTime is limited by DateTime.UtcNow.
/// </summary>
DateTime CommandCreated { get; }
/// <summary>
/// How long this command waited to be added to the queue of pending
/// redis commands. A large TimeSpan indicates serious contention for
/// the pending queue.
/// </summary>
TimeSpan CreationToEnqueued { get; }
/// <summary>
/// How long this command spent in the pending queue before being sent to redis.
/// A large TimeSpan can indicate a large number of pending events, large pending events,
/// or network issues.
/// </summary>
TimeSpan EnqueuedToSending { get; }
/// <summary>
/// How long before Redis responded to this command and it's response could be handled after it was sent.
/// A large TimeSpan can indicate a large response body, an overtaxed redis instance, or network issues.
/// </summary>
TimeSpan SentToResponse { get; }
/// <summary>
/// How long between Redis responding to this command and awaiting consumers being notified.
/// </summary>
TimeSpan ResponseToCompletion { get; }
/// <summary>
/// How long it took this redis command to be processed, from creation to deserializing the final response.
///
/// Note that this TimeSpan *does not* include time spent awaiting a Task in consumer code.
/// </summary>
TimeSpan ElapsedTime { get; }
/// <summary>
/// If a command has to be resent due to an ASK or MOVED response from redis (in a cluster configuration),
/// the second sending of the command will have this property set to the original IProfiledCommand.
///
/// This can only be set if redis is configured as a cluster.
/// </summary>
IProfiledCommand RetransmissionOf { get; }
/// <summary>
/// If RetransmissionOf is not null, this property will be set to either Ask or Moved to indicate
/// what sort of response triggered the retransmission.
///
/// This can be useful for determining the root cause of extra commands.
/// </summary>
RetransmissionReasonType? RetransmissionReason { get; }
}
/// <summary>
/// Interface for profiling individual commands against an Redis ConnectionMulitplexer.
/// </summary>
public interface IProfiler
{
/// <summary>
/// Called to provide a context object.
///
/// This method is called before the method which triggers work against redis (such as StringSet(Async)) returns,
/// and will always be called on the same thread as that method.
///
/// Note that GetContext() may be called even if ConnectionMultiplexer.BeginProfiling() has not been called.
/// You may return `null` to prevent any tracking of commands.
/// </summary>
object GetContext();
}
}
using System;
using System.Net;
namespace StackExchange.Redis
{
/// <summary>
/// A profiled command against a redis instance.
///
/// TimeSpans returned by this interface use a high precision timer if possible.
/// DateTimes returned by this interface are no more precise than DateTime.UtcNow.
/// </summary>
public interface IProfiledCommand
{
/// <summary>
/// The endpoint this command was sent to.
/// </summary>
EndPoint EndPoint { get; }
/// <summary>
/// The Db this command was sent to.
/// </summary>
int Db { get; }
/// <summary>
/// The name of this command.
/// </summary>
string Command { get; }
/// <summary>
/// The CommandFlags the command was submitted with.
/// </summary>
CommandFlags Flags { get; }
/// <summary>
/// When this command was *created*, will be approximately
/// when the paired method of StackExchange.Redis was called but
/// before that method returned.
///
/// Note that the resolution of the returned DateTime is limited by DateTime.UtcNow.
/// </summary>
DateTime CommandCreated { get; }
/// <summary>
/// How long this command waited to be added to the queue of pending
/// redis commands. A large TimeSpan indicates serious contention for
/// the pending queue.
/// </summary>
TimeSpan CreationToEnqueued { get; }
/// <summary>
/// How long this command spent in the pending queue before being sent to redis.
/// A large TimeSpan can indicate a large number of pending events, large pending events,
/// or network issues.
/// </summary>
TimeSpan EnqueuedToSending { get; }
/// <summary>
/// How long before Redis responded to this command and it's response could be handled after it was sent.
/// A large TimeSpan can indicate a large response body, an overtaxed redis instance, or network issues.
/// </summary>
TimeSpan SentToResponse { get; }
/// <summary>
/// How long between Redis responding to this command and awaiting consumers being notified.
/// </summary>
TimeSpan ResponseToCompletion { get; }
/// <summary>
/// How long it took this redis command to be processed, from creation to deserializing the final response.
///
/// Note that this TimeSpan *does not* include time spent awaiting a Task in consumer code.
/// </summary>
TimeSpan ElapsedTime { get; }
/// <summary>
/// If a command has to be resent due to an ASK or MOVED response from redis (in a cluster configuration),
/// the second sending of the command will have this property set to the original IProfiledCommand.
///
/// This can only be set if redis is configured as a cluster.
/// </summary>
IProfiledCommand RetransmissionOf { get; }
/// <summary>
/// If RetransmissionOf is not null, this property will be set to either Ask or Moved to indicate
/// what sort of response triggered the retransmission.
///
/// This can be useful for determining the root cause of extra commands.
/// </summary>
RetransmissionReasonType? RetransmissionReason { get; }
}
/// <summary>
/// Interface for profiling individual commands against an Redis ConnectionMulitplexer.
/// </summary>
public interface IProfiler
{
/// <summary>
/// Called to provide a context object.
///
/// This method is called before the method which triggers work against redis (such as StringSet(Async)) returns,
/// and will always be called on the same thread as that method.
///
/// Note that GetContext() may be called even if ConnectionMultiplexer.BeginProfiling() has not been called.
/// You may return `null` to prevent any tracking of commands.
/// </summary>
object GetContext();
}
}
......@@ -11,32 +11,12 @@ public partial interface IRedis : IRedisAsync
/// <summary>
/// This command is often used to test if a connection is still alive, or to measure latency.
/// </summary>
/// <param name="flags">The command flags to use when pinging.</param>
/// <returns>The observed latency.</returns>
/// <remarks>https://redis.io/commands/ping</remarks>
TimeSpan Ping(CommandFlags flags = CommandFlags.None);
}
/// <summary>
/// Represents a resumable, cursor-based scanning operation
/// </summary>
public interface IScanningCursor
{
/// <summary>
/// Returns the cursor that represents the *active* page of results (not the pending/next page of results as returned by SCAN/HSCAN/ZSCAN/SSCAN)
/// </summary>
long Cursor { get; }
/// <summary>
/// The page size of the current operation
/// </summary>
int PageSize { get; }
/// <summary>
/// The offset into the current page
/// </summary>
int PageOffset { get; }
}
[Conditional("DEBUG")]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
internal class IgnoreNamePrefixAttribute : Attribute
......@@ -46,6 +26,6 @@ public IgnoreNamePrefixAttribute(bool ignoreEntireMethod = false)
IgnoreEntireMethod = ignoreEntireMethod;
}
public bool IgnoreEntireMethod { get; private set; }
public bool IgnoreEntireMethod { get; }
}
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ public partial interface IRedisAsync
/// <returns>The observed latency.</returns>
/// <remarks>https://redis.io/commands/ping</remarks>
Task<TimeSpan> PingAsync(CommandFlags flags = CommandFlags.None);
/// <summary>
/// Wait for a given asynchronous operation to complete (or timeout), reporting which
/// </summary>
......@@ -28,14 +29,15 @@ public partial interface IRedisAsync
/// Wait for a given asynchronous operation to complete (or timeout)
/// </summary>
void Wait(Task task);
/// <summary>
/// Wait for a given asynchronous operation to complete (or timeout)
/// </summary>
T Wait<T>(Task<T> task);
/// <summary>
/// Wait for the given asynchronous operations to complete (or timeout)
/// </summary>
void WaitAll(params Task[] tasks);
}
}
namespace StackExchange.Redis
{
/// <summary>
/// Represents a resumable, cursor-based scanning operation
/// </summary>
public interface IScanningCursor
{
/// <summary>
/// Returns the cursor that represents the *active* page of results (not the pending/next page of results as returned by SCAN/HSCAN/ZSCAN/SSCAN)
/// </summary>
long Cursor { get; }
/// <summary>
/// The page size of the current operation
/// </summary>
int PageSize { get; }
/// <summary>
/// The offset into the current page
/// </summary>
int PageOffset { get; }
}
}
\ No newline at end of file
......@@ -51,7 +51,7 @@ public partial interface IServer : IRedis
/// Gets the version of the connected server
/// </summary>
Version Version { get; }
/// <summary>
/// The CLIENT KILL command closes a given client connection identified by ip:port.
/// The ip:port should match a line returned by the CLIENT LIST command.
......@@ -74,6 +74,7 @@ public partial interface IServer : IRedis
/// <returns>the number of clients killed.</returns>
/// <remarks>https://redis.io/commands/client-kill</remarks>
long ClientKill(long? id = null, ClientType? clientType = null, EndPoint endpoint = null, bool skipMe = true, CommandFlags flags = CommandFlags.None);
/// <summary>
/// The CLIENT KILL command closes multiple connections that match the specified filters
/// </summary>
......@@ -349,6 +350,7 @@ public partial interface IServer : IRedis
/// </summary>
/// <remarks>https://redis.io/commands/slaveof</remarks>
void SlaveOf(EndPoint master, CommandFlags flags = CommandFlags.None);
/// <summary>
/// The SLAVEOF command can change the replication settings of a slave on the fly. If a Redis server is already acting as slave, specifying a null master will turn off the replication, turning the Redis server into a MASTER. Specifying a non-null master will make the server a slave of another server listening at the specified hostname and port.
/// </summary>
......@@ -360,21 +362,25 @@ public partial interface IServer : IRedis
/// </summary>
/// <remarks>https://redis.io/commands/slowlog</remarks>
CommandTrace[] SlowlogGet(int count = 0, CommandFlags flags = CommandFlags.None);
/// <summary>
/// To read the slow log the SLOWLOG GET command is used, that returns every entry in the slow log. It is possible to return only the N most recent entries passing an additional argument to the command (for instance SLOWLOG GET 10).
/// </summary>
/// <remarks>https://redis.io/commands/slowlog</remarks>
Task<CommandTrace[]> SlowlogGetAsync(int count = 0, CommandFlags flags = CommandFlags.None);
/// <summary>
/// You can reset the slow log using the SLOWLOG RESET command. Once deleted the information is lost forever.
/// </summary>
/// <remarks>https://redis.io/commands/slowlog</remarks>
void SlowlogReset(CommandFlags flags = CommandFlags.None);
/// <summary>
/// You can reset the slow log using the SLOWLOG RESET command. Once deleted the information is lost forever.
/// </summary>
/// <remarks>https://redis.io/commands/slowlog</remarks>
Task SlowlogResetAsync(CommandFlags flags = CommandFlags.None);
/// <summary>
/// Lists the currently active channels. An active channel is a Pub/Sub channel with one ore more subscribers (not including clients subscribed to patterns).
/// </summary>
......@@ -421,6 +427,7 @@ public partial interface IServer : IRedis
/// <returns>The server's current time.</returns>
/// <remarks>https://redis.io/commands/time</remarks>
DateTime Time(CommandFlags flags = CommandFlags.None);
/// <summary>
/// The TIME command returns the current server time.
/// </summary>
......@@ -523,7 +530,4 @@ public partial interface IServer : IRedis
#endregion
}
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ namespace StackExchange.Redis
/// </summary>
public interface ISubscriber : IRedis
{
/// <summary>
/// Inidicate exactly which redis server we are talking to
/// </summary>
......@@ -36,12 +35,14 @@ public interface ISubscriber : IRedis
/// <returns>the number of clients that received the message.</returns>
/// <remarks>https://redis.io/commands/publish</remarks>
long Publish(RedisChannel channel, RedisValue message, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Posts a message to the given channel.
/// </summary>
/// <returns>the number of clients that received the message.</returns>
/// <remarks>https://redis.io/commands/publish</remarks>
Task<long> PublishAsync(RedisChannel channel, RedisValue message, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Subscribe to perform some operation when a change to the preferred/active node is broadcast.
/// </summary>
......
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