コード例 #1
0
        private static void ActOnCommitCheckFailure(IEnvelope envelope, Guid correlationId, CommitCheckResult result)
        {
            switch (result.Decision)
            {
            case CommitDecision.WrongExpectedVersion:
                envelope.ReplyWith(new StorageMessage.WrongExpectedVersion(correlationId, result.CurrentVersion));
                break;

            case CommitDecision.Deleted:
                envelope.ReplyWith(new StorageMessage.StreamDeleted(correlationId));
                break;

            case CommitDecision.Idempotent:
                envelope.ReplyWith(new StorageMessage.AlreadyCommitted(correlationId,
                                                                       result.EventStreamId,
                                                                       result.StartEventNumber,
                                                                       result.EndEventNumber));
                break;

            case CommitDecision.CorruptedIdempotency:
                // in case of corrupted idempotency (part of transaction is ok, other is different)
                // then we can say that the transaction is not idempotent, so WrongExpectedVersion is ok answer
                envelope.ReplyWith(new StorageMessage.WrongExpectedVersion(correlationId, result.CurrentVersion));
                break;

            case CommitDecision.InvalidTransaction:
                envelope.ReplyWith(new StorageMessage.InvalidTransaction(correlationId));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #2
0
        private static void ActOnCommitCheckFailure(IEnvelope envelope, Guid correlationId, CommitCheckResult result)
        {
            switch (result.Decision)
            {
            case CommitDecision.WrongExpectedVersion:
                envelope.ReplyWith(new StorageMessage.WrongExpectedVersion(correlationId, result.CurrentVersion));
                break;

            case CommitDecision.Deleted:
                envelope.ReplyWith(new StorageMessage.StreamDeleted(correlationId));
                break;

            case CommitDecision.Idempotent:
                envelope.ReplyWith(new StorageMessage.AlreadyCommitted(correlationId,
                                                                       result.EventStreamId,
                                                                       result.StartEventNumber,
                                                                       result.EndEventNumber,
                                                                       result.IdempotentLogPosition));
                break;

            case CommitDecision.CorruptedIdempotency:
                // in case of corrupted idempotency (part of transaction is ok, other is different)
                // then we can say that the transaction is not idempotent, so WrongExpectedVersion is ok answer
                envelope.ReplyWith(new StorageMessage.WrongExpectedVersion(correlationId, result.CurrentVersion));
                break;

            case CommitDecision.InvalidTransaction:
                envelope.ReplyWith(new StorageMessage.InvalidTransaction(correlationId));
                break;

            case CommitDecision.IdempotentNotReady:
                //TODO(clc): when we have the pre-index we should be able to get the logPosition from the pre-index and allow the transaction to wait for the cluster commit
                //just drop the write and wait for the client to retry
                Log.Debug("Dropping idempotent write to stream {@stream}, startEventNumber: {@startEventNumber}, endEventNumber: {@endEventNumber} since the original write has not yet been replicated.", result.EventStreamId, result.StartEventNumber, result.EndEventNumber);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }