public void RemoveReplica(ReplicaId id) { var desc = replicas[id]; replicas.Remove(id); ReplicaRemoved?.Invoke(desc); }
public void UpdateReplica(ReplicaId id, ByteString replica) { var desc = replicas[id]; desc.Value.MergeFrom(replica); ReplicaUpdated?.Invoke(desc); }
internal void AddReplica(ReplicaId id, IMessage replica, ReplicaOptions options) { var desc = new Replica(id, replica, options); replicas.Add(desc.Id, desc); ReplicaAdded?.Invoke(desc); }
public void AddStaticReplica(ReplicaId id, IMessage replica, StaticReplicaOptions options) { if (id < 0 || StaticIdCount <= id) { throw new ArgumentException($"{nameof(id)} must be in range [0,{StaticIdCount}["); } ReplicaOptions replicaOptions = (ReplicaOptions)options; AddReplica(id, replica, replicaOptions); }
public ReplicaId AddDynamicReplica(IMessage replica, DynamicReplicaOptions options = DynamicReplicaOptions.DefaultMaster) { ReplicaOptions replicaOptions = (ReplicaOptions)options; replicaOptions |= ReplicaOptions.AddOrRemove; replicaOptions |= ReplicaOptions.Master; ReplicaId id = GetNextDynamicId(); AddReplica(id, replica, replicaOptions); return(id); }
internal Replica(ReplicaId id, IMessage value, ReplicaOptions options) { Id = id; Value = value; Options = options; }
public Replica GetReplica(ReplicaId replicaId) { return(replicas[replicaId]); }
public void UpdateReplica(ReplicaId id) { var desc = replicas[id]; ReplicaUpdated?.Invoke(desc); }
public void UpdateReplica(ReplicaId id, IMessage replica) { UpdateReplica(id, replica.ToByteString()); }
public T GetReplica <T>(ReplicaId replicaId) where T : IMessage { return((T)(GetReplica(replicaId).Value)); }