Commit d44b99f8 authored by Marc Gravell's avatar Marc Gravell

Merge pull request #117 from stepaside/master

Added ability to write to a non-readonly slave
parents dbe1c4d0 247d08a9
......@@ -37,6 +37,11 @@ public partial interface IServer : IRedis
/// </summary>
bool IsSlave { get; }
/// <summary>
/// Explicitly opt in for slave writes on writable slaves
/// </summary>
bool AllowSlaveWrites { get; set; }
/// <summary>
/// Gets the operating mode of the connected server
/// </summary>
......@@ -46,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.
......
......@@ -753,7 +753,7 @@ private bool WriteMessageToServer(PhysicalConnection connection, Message message
{
var cmd = message.Command;
bool isMasterOnly = message.IsMasterOnly();
if (isMasterOnly && serverEndPoint.IsSlave)
if (isMasterOnly && serverEndPoint.IsSlave && (serverEndPoint.SlaveReadOnly || !serverEndPoint.AllowSlaveWrites))
{
throw ExceptionFactory.MasterOnly(multiplexer.IncludeDetailInExceptions, message.Command, message, ServerEndPoint);
}
......
......@@ -37,6 +37,12 @@ public RedisFeatures Features
public bool IsSlave { get { return server.IsSlave; } }
public bool AllowSlaveWrites
{
get { return server.AllowSlaveWrites; }
set { server.AllowSlaveWrites = value; }
}
public ServerType ServerType { get { return server.ServerType; } }
public Version Version { get { return server.Version; } }
......
......@@ -114,6 +114,8 @@ public long OperationCount
public bool SlaveReadOnly { get { return slaveReadOnly; } set { SetConfig(ref slaveReadOnly, value); } }
public bool AllowSlaveWrites { get; set; }
public Version Version { get { return version; } set { SetConfig(ref version, value); } }
public int WriteEverySeconds { get { return writeEverySeconds; } set { SetConfig(ref writeEverySeconds, value); } }
......
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