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