Пример #1
0
        async Task <GangState <TStateData> > IGangStateStore
        .CommitAsync <TStateData>(string gangId, GangState <TStateData> state, GangAudit audit)
        {
            var version = state.Version - (uint)state.Uncommitted.Count;

            foreach (var eventData in state.Uncommitted)
            {
                var e       = GangStateEvent.From(eventData, audit);
                var wrapper = new GangStateEventWrapper(
                    eventData,
                    GangStateEventMap.GetName <TStateData>(eventData.GetType()),
                    audit.SetVersion(++version)
                    );

                _events.OnNext(e);

                var key = GetEventKey(++_sequenceNumber);

                await _eventStore.SetAsync(
                    key, wrapper,
                    overwrite : false
                    );
            }

            await _cache.SetAsync(gangId,
                                  new { state.Data, state.Version }
                                  );

            await _sequenceNumberStore.SetAsync(KEY_SEQUENCE_NUMBER, _sequenceNumber);

            return(GangState.Create(state.Data, state.Version));
        }
Пример #2
0
 Task IGangSessionUserStore
 .SetAsync(GangSessionUser value)
 {
     return(_store.SetAsync(value.Id, value));
 }
Пример #3
0
 Task <GangUserData> IGangUserStore
 .SetAsync(GangUserData value)
 {
     return(_store.SetAsync(value.Id, value));
 }