public RedisHost(RedisModule module, RedisSettings.Server server) { Module = module; HostName = server.Name; Region = Module.Settings.Replication?.RegionHostRegex?.Match(HostName)?.Value ?? "Global"; ReplicationGroupName = server.ReplicationGroup; }
public static RedisInstanceOperation FromString(RedisModule module, string s) { var parts = s.Split(StringSplits.VerticalBar); if (parts.Length > 1 && Enum.TryParse <InstanceCommandType>(parts[0], out var opType)) { var opee = module.Instances.Find(i => i.UniqueKey == parts[1]); switch (opType) { case InstanceCommandType.MakeMaster: return(MakeMaster(opee)); case InstanceCommandType.SlaveTo: var newMaster = module.Instances.Find(i => i.UniqueKey == parts[2]); return(SlaveTo(opee, newMaster)); default: throw new ArgumentOutOfRangeException(nameof(InstanceCommandType)); } } throw new ArgumentOutOfRangeException(nameof(s), $"Invalid op string provided: '{s}'"); }