protected override bool Receive(object message) => message.Match() .With <WriteAck>(x => { Remaining = Remaining.Remove(SenderAddress); if (IsDone) { Reply(isTimeout: false); } }) .With <WriteNack>(x => { _gotNackFrom = _gotNackFrom.Add(SenderAddress); if (IsDone) { Reply(isTimeout: false); } }) .With <DeltaNack>(_ => { // ok, will be retried with full state }) .With <UpdateSuccess>(x => { _gotLocalStoreReply = true; if (IsDone) { Reply(isTimeout: false); } }) .With <StoreFailure>(x => { _gotLocalStoreReply = true; _gotNackFrom = _gotNackFrom.Remove(_selfUniqueAddress.Address); if (IsDone) { Reply(isTimeout: false); } }) .With <SendToSecondary>(x => { // Deltas must be applied in order and we can't keep track of ordering of // simultaneous updates so there is a chance that the delta could not be applied. // Try again with the full state to the primary nodes that have not acked. if (_delta != null) { foreach (var address in PrimaryNodes.Intersect(Remaining)) { Replica(address).Tell(_write); } } foreach (var n in SecondaryNodes) { Replica(n).Tell(_write); } }) .With <ReceiveTimeout>(x => Reply(isTimeout: true)) .WasHandled;
protected override bool Receive(object message) { switch (message) { case WriteAck _: Remaining = Remaining.Remove(SenderAddress); if (IsDone) { Reply(isTimeout: false); } return(true); case WriteNack _: _gotNackFrom = _gotNackFrom.Add(SenderAddress); if (IsDone) { Reply(isTimeout: false); } return(true); case DeltaNack _: Sender.Tell(_write); return(true); case UpdateSuccess _: _gotLocalStoreReply = true; if (IsDone) { Reply(isTimeout: false); } return(true); case StoreFailure _: _gotLocalStoreReply = true; _gotNackFrom = _gotNackFrom.Add(_selfUniqueAddress.Address); if (IsDone) { Reply(isTimeout: false); } return(true); case SendToSecondary _: if (_delta != null) { // Deltas must be applied in order and we can't keep track of ordering of // simultaneous updates so there is a chance that the delta could not be applied. // Try again with the full state to the primary nodes that have not acked. foreach (var address in PrimaryNodes.Intersect(Remaining)) { Replica(address).Tell(_write); } } foreach (var n in SecondaryNodes) { Replica(n).Tell(_write); } return(true); case ReceiveTimeout _: Reply(isTimeout: true); return(true); } return(false); }