csharp/2881099/csredis/src/CSRedisCore/RedisSentinelClient.Async.cs

RedisSentinelClient.Async.cs
using CSRedis.Internal.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

#if net40
#else
namespace CSRedis
{
    public partial clast RedisSentinelClient
    {
        /// 
        /// Connect to the remote host
        /// 
        /// True if connected
        public Task ConnectAsync()
        {
            return _connector.ConnectAsync();
        }

        /// 
        /// Call arbitrary Sentinel command (e.g. for a command not yet implemented in this library)
        /// 
        /// The name of the command
        /// Array of arguments to the command
        /// Redis unified response
        public Task CallAsync(string command, params string[] args)
        {
            return WriteAsync(new RedisObject(command, args));
        }

        Task WriteAsync(RedisCommand command)
        {
            return _connector.CallAsync(command);
        }

        #region sentinel
        /// 
        /// Ping the Sentinel server
        /// 
        /// Status code
        public Task PingAsync()
        {
            return WriteAsync(RedisCommands.Ping());
        }

        /// 
        /// Get a list of monitored Redis masters
        /// 
        /// Redis master info
        public Task MastersAsync()
        {
            return WriteAsync(RedisCommands.Sentinel.Masters());
        }

        /// 
        /// Get information on the specified Redis master
        /// 
        /// Name of the Redis master
        /// Master information
        public Task MasterAsync(string masterName)
        {
            return WriteAsync(RedisCommands.Sentinel.Master(masterName));
        }

        /// 
        /// Get a list of other Sentinels known to the current Sentinel
        /// 
        /// Name of monitored master
        /// Sentinel hosts and ports
        public Task SentinelsAsync(string masterName)
        {
            return WriteAsync(RedisCommands.Sentinel.Sentinels(masterName));
        }


        /// 
        /// Get a list of monitored Redis slaves to the given master 
        /// 
        /// Name of monitored master
        /// Redis slave info
        public Task SlavesAsync(string masterName)
        {
            return WriteAsync(RedisCommands.Sentinel.Slaves(masterName));
        }

        /// 
        /// Get the IP and port of the current master Redis server
        /// 
        /// Name of monitored master
        /// IP and port of master Redis server
        public Task GetMasterAddrByNameAsync(string masterName)
        {
            return WriteAsync(RedisCommands.Sentinel.GetMasterAddrByName(masterName));
        }

        /// 
        /// Get master state information
        /// 
        /// Host IP
        /// Host port
        /// Current epoch
        /// Run ID
        /// Master state
        public Task IsMasterDownByAddrAsync(string ip, int port, long currentEpoch, string runId)
        {
            return WriteAsync(RedisCommands.Sentinel.IsMasterDownByAddr(ip, port, currentEpoch, runId));
        }

        /// 
        /// Clear state in all masters with matching name
        /// 
        /// Master name pattern
        /// Number of masters that were reset
        public Task ResetAsync(string pattern)
        {
            return WriteAsync(RedisCommands.Sentinel.Reset(pattern));
        }

        /// 
        /// Force a failover as if the master was not reachable, and without asking for agreement from other sentinels
        /// 
        /// Master name
        /// Status code
        public Task FailoverAsync(string masterName)
        {
            return WriteAsync(RedisCommands.Sentinel.Failover(masterName));
        }

        /// 
        /// Start monitoring a new master
        /// 
        /// Master name
        /// Master port
        /// Quorum count
        /// Status code
        public Task MonitorAsync(string name, int port, int quorum)
        {
            return WriteAsync(RedisCommands.Sentinel.Monitor(name, port, quorum));
        }

        /// 
        /// Remove the specified master
        /// 
        /// Master name
        /// Status code
        public Task RemoveAsync(string name)
        {
            return WriteAsync(RedisCommands.Sentinel.Remove(name));
        }

        /// 
        /// Change configuration parameters of a specific master
        /// 
        /// Master name
        /// Config option name
        /// Config option value
        /// Status code
        public Task SetAsync(string masterName, string option, string value)
        {
            return WriteAsync(RedisCommands.Sentinel.Set(masterName, option, value));
        }
        #endregion
    }
}
#endif