Beispiel #1
0
        public async Task <TResult> ExecuteAsync <TResult>(Command <TModel, TResult> command)
        {
            var completionSource = new TaskCompletionSource <object>();

            _pendingLocalCommands[command.Id] = completionSource;
            _journalWriter.Send(command);
            return((TResult)await completionSource.Task.ConfigureAwait(false));
        }
Beispiel #2
0
        public async Task <TResult> ExecuteAsync <TResult>(Command <TModel, TResult> command)
        {
            EnsureOperational();
            var completionSource = new TaskCompletionSource <object>();

            _pendingLocalCommands[command.Id] = completionSource;
            _metrics.PendingLocalCommands(_pendingLocalCommands.Count);

            using (_metrics.MeasureCommandExecution())
            {
                _journalWriter.Send(command);
                return((TResult)await completionSource.Task.ConfigureAwait(false));
            }
        }
Beispiel #3
0
        public void CanWrite()
        {
            var create = new Create(Guid.NewGuid(), "Create a Postgresql driver for Memstate");

            _journalWriter.Send(create);

            Thread.Sleep(500);

            var journalRecords = GetJournalRecords();

            Assert.Single(journalRecords);
        }
Beispiel #4
0
        public void CanWrite()
        {
            var create = new Create(Guid.NewGuid(), "Resolve a Postgresql driver for Memstate");

            _journalWriter.Send(create);

            Thread.Sleep(500);

            var journalRecords = GetJournalRecords();

            Assert.AreEqual(1, journalRecords.Count());
        }
Beispiel #5
0
        /// <summary>
        /// Execute non-generically typed command
        /// </summary>
        internal Task <object> ExecuteUntyped(Command command)
        {
            EnsureOperational();

            var completionSource = new TaskCompletionSource <object>();

            _pendingLocalCommands[command.Id] = completionSource;

            _metrics.PendingLocalCommands(_pendingLocalCommands.Count);

            using (_metrics.MeasureCommandExecution())
            {
                _journalWriter.Send(command);
                return(completionSource.Task);
            }
        }