Пример #1
0
        private CommitForStorage getCommit(NetMQMessage message)
        {
            var context = message.Pop().ConvertToString();
            var stream = message.Pop().ConvertToString();
            var expectedVersion = message.PopInt64();
            var eventCount = message.PopInt32();

            var events = new EventForStorage[eventCount];

            for (int i = 0; i < eventCount; i++)
            {
                var eventId = new Guid(message.Pop().ToByteArray());
                var timestamp = message.PopDateTime();
                var typeKey = message.PopString();
                var headers = message.PopStringOrNull();
                var body = message.PopString();

                //-1 to override concurrency check. Being lazy and not using a constant.
                var version = expectedVersion == -1 ? -1 : expectedVersion + i;

                events[i] = new EventForStorage(eventId, version, timestamp, typeKey, headers, body);
            }

            return new CommitForStorage(context, stream, events);
        }
Пример #2
0
 public ExpectingAnotherEventOrCommit Event(EventForStorage e)
 {
     _instance._entries[_commit].Add(e);
     return this;
 }
Пример #3
0
 public ExpectingAnotherEventOrCommit Event(EventForStorage e)
 {
     _instance._entries[_commit] = new List<EventForStorage> {e};
     return new ExpectingAnotherEventOrCommit(_commit, _instance);
 }
Пример #4
0
        private string storeEvent(string context, string typeKey, string body, string stream)
        {
            var @event = new EventForStorage(Guid.NewGuid(), 1, DateTime.UtcNow, typeKey, null, body);
            var commit = new CommitForStorage(Guid.NewGuid(), context, stream, @event);
            var commits = new CommitsForStorage(commit);
            _storage.Store(commits);

            return stream;
        }