示例#1
0
        public async Task RunAsync(SagaFlow flow)
        {
            _ = _activated.Value;
            if (StateData.SagaFlowState != null !)
            {
                if (StateData.SagaFlowState.IsCompleted)
                {
                    _logger.LogInformation("saga flow already completed");
                    return;
                }
            }
            else
            {
                _logger.LogInformation("saga flow is not built, start to build it");
                var evt = new SagaFlowCreateEvent
                {
                    Steps           = flow.Steps,
                    CompensateSteps = flow.CompensateSteps,
                    UserData        = _sagaUserDataSerializer.Serialize(flow.UserData, flow.UserData.GetType()),
                    UserDataType    = flow.UserData.GetType()
                };

                await Claptrap.HandleEventAsync(new DataEvent(_identity, SagaCodes.Create, evt));
            }

            await ContinueAsync();
        }
示例#2
0
        public SagaFlow Build()
        {
            var re = new SagaFlow
            {
                Steps           = _steps,
                CompensateSteps = _compensateSteps,
                UserData        = _userData,
            };

            return(re);
        }
 public Task RunAsync(SagaFlow flow)
 {
     return(_sagaClaptrap.RunAsync(flow));
 }