snatch-dev / Chronicle

Implementation of saga pattern for .NET Core
MIT License
397 stars 70 forks source link

Saga parallelism #53

Open dima-zhemkov opened 4 years ago

dima-zhemkov commented 4 years ago

It would be good to be able to perform optimistic concurrency check to avoid data corruption when running a few instances at the same time.

I propose to add Revision property of type uint to the ISagaState.

GooRiOn commented 4 years ago

Hi, I believe such thing is covered inside ISagaCoordinator:

using (await Locker.LockAsync(id))
            {
                var (isInitialized, state) = await _initializer.TryInitializeAsync(saga, id, message);

                if (!isInitialized)
                {
                    return;
                }

                await _processor.ProcessAsync(saga, message, state, context);
                await _postProcessor.ProcessAsync(saga, message, context, onCompleted, onRejected);
            }

Therefore adding the revision/version should not be necessary.

dima-zhemkov commented 4 years ago

Hi, I believe such thing is covered inside ISagaCoordinator:

using (await Locker.LockAsync(id))
            {
                var (isInitialized, state) = await _initializer.TryInitializeAsync(saga, id, message);

                if (!isInitialized)
                {
                    return;
                }

                await _processor.ProcessAsync(saga, message, state, context);
                await _postProcessor.ProcessAsync(saga, message, context, onCompleted, onRejected);
            }

Therefore adding the revision/version should not be necessary.

It will work only if you process saga on a single PC.

GooRiOn commented 3 years ago

That's a good point... I need to come up with some sort of distributed storage for such a scenario. Will do my best to deliver this quite soon.

xNarkon commented 3 years ago

That's a good point... I need to come up with some sort of distributed storage for such a scenario. Will do my best to deliver this quite soon.

Any update :D?