예제 #1
0
 private void InitializeSaga(ISaga saga, SagaId id, ISagaState state)
 {
     if (state.Data is null)
     {
         saga.Initialize(id, state.State);
     }
     else
     {
         saga.InvokeGeneric(nameof(ISaga <object> .Initialize), id, state.State, state.Data);
     }
 }
예제 #2
0
        private async Task CompensateAsync(ISaga saga, Type sagaType, ISagaContext context)
        {
            var sagaLogs = await _log.ReadAsync(saga.Id, sagaType);

            sagaLogs.OrderByDescending(l => l.CreatedAt)
            .Select(l => l.Message)
            .ToList()
            .ForEach(async message =>
            {
                await((Task)saga.InvokeGeneric(nameof(ISagaAction <object> .CompensateAsync), message, context))
                .ConfigureAwait(false);
            });
        }