diff --git a/Pole.sln b/Pole.sln
index fe4317f..e623eff 100644
--- a/Pole.sln
+++ b/Pole.sln
@@ -39,6 +39,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pole.Orleans.Provider.Entit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pole.Samples.Backet.Api", "test\Pole.Samples.Backet.Api\Pole.Samples.Backet.Api.csproj", "{FB3D2F52-123A-4606-B682-9159BD7913AE}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pole.Sagas", "src\Pole.Sagas\Pole.Sagas.csproj", "{1F06D877-E4EC-4908-9057-38EDCE5E54E6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pole.Sagas.Storage.PostgreSql", "src\Pole.Sagas.Storage.PostgreSql\Pole.Sagas.Storage.PostgreSql.csproj", "{9505BDFC-395B-4257-AEB3-2B44611147A4}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -93,6 +97,14 @@ Global
{FB3D2F52-123A-4606-B682-9159BD7913AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB3D2F52-123A-4606-B682-9159BD7913AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB3D2F52-123A-4606-B682-9159BD7913AE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1F06D877-E4EC-4908-9057-38EDCE5E54E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1F06D877-E4EC-4908-9057-38EDCE5E54E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1F06D877-E4EC-4908-9057-38EDCE5E54E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1F06D877-E4EC-4908-9057-38EDCE5E54E6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9505BDFC-395B-4257-AEB3-2B44611147A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9505BDFC-395B-4257-AEB3-2B44611147A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9505BDFC-395B-4257-AEB3-2B44611147A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9505BDFC-395B-4257-AEB3-2B44611147A4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -113,6 +125,8 @@ Global
{548EFDBB-252F-48DD-87F4-58ABFBD4963C} = {9932C965-8B38-4F70-9E43-86DC56860E2B}
{0DA75F4A-BF47-4B52-B932-48BB6A709934} = {9932C965-8B38-4F70-9E43-86DC56860E2B}
{FB3D2F52-123A-4606-B682-9159BD7913AE} = {655E719B-4A3E-467C-A541-E0770AB81DE1}
+ {1F06D877-E4EC-4908-9057-38EDCE5E54E6} = {9932C965-8B38-4F70-9E43-86DC56860E2B}
+ {9505BDFC-395B-4257-AEB3-2B44611147A4} = {9932C965-8B38-4F70-9E43-86DC56860E2B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DB0775A3-F293-4043-ADB7-72BAC081E87E}
diff --git a/src/Pole.Sagas.Storage.PostgreSql/Pole.Sagas.Storage.PostgreSql.csproj b/src/Pole.Sagas.Storage.PostgreSql/Pole.Sagas.Storage.PostgreSql.csproj
new file mode 100644
index 0000000..9f5c4f4
--- /dev/null
+++ b/src/Pole.Sagas.Storage.PostgreSql/Pole.Sagas.Storage.PostgreSql.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netstandard2.0
+
+
+
diff --git a/src/Pole.Sagas/Core/ActivityExecuteResult.cs b/src/Pole.Sagas/Core/ActivityExecuteResult.cs
new file mode 100644
index 0000000..93f7b76
--- /dev/null
+++ b/src/Pole.Sagas/Core/ActivityExecuteResult.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Core
+{
+ public class ActivityExecuteResult
+ {
+ public bool IsSuccess { get; set; }
+ public string Message { get; set; }
+ }
+}
diff --git a/src/Pole.Sagas/Core/Exceptions/SagaNotFoundException.cs b/src/Pole.Sagas/Core/Exceptions/SagaNotFoundException.cs
new file mode 100644
index 0000000..317f127
--- /dev/null
+++ b/src/Pole.Sagas/Core/Exceptions/SagaNotFoundException.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Core.Exceptions
+{
+ public class SagaNotFoundException:Exception
+ {
+ public SagaNotFoundException(string sagaName):base($"Saga:{sagaName} not found")
+ {
+
+ }
+ }
+}
diff --git a/src/Pole.Sagas/Core/IActivity.cs b/src/Pole.Sagas/Core/IActivity.cs
new file mode 100644
index 0000000..b186b54
--- /dev/null
+++ b/src/Pole.Sagas/Core/IActivity.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Pole.Sagas.Core
+{
+ public interface IActivity
+ {
+ Task Execute(TData data);
+ Task Compensate(TData data);
+ }
+}
diff --git a/src/Pole.Sagas/Core/ISaga.cs b/src/Pole.Sagas/Core/ISaga.cs
new file mode 100644
index 0000000..25a52be
--- /dev/null
+++ b/src/Pole.Sagas/Core/ISaga.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Core
+{
+ public interface ISaga
+ {
+ void AddActivity(IActivity activity);
+ }
+}
diff --git a/src/Pole.Sagas/Core/ISagaFactory.cs b/src/Pole.Sagas/Core/ISagaFactory.cs
new file mode 100644
index 0000000..2ad9dd9
--- /dev/null
+++ b/src/Pole.Sagas/Core/ISagaFactory.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Core
+{
+ public interface ISagaFactory
+ {
+ TSaga CreateSaga(TimeSpan timeOut) where TSaga : ISaga;
+ }
+}
diff --git a/src/Pole.Sagas/Core/Saga.cs b/src/Pole.Sagas/Core/Saga.cs
new file mode 100644
index 0000000..19f02ad
--- /dev/null
+++ b/src/Pole.Sagas/Core/Saga.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Core
+{
+ class Saga : ISaga
+ {
+ private System.Collections.Concurrent.ConcurrentQueue<>
+ public void AddActivity(IActivity activity)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/Pole.Sagas/Core/SagaFactory.cs b/src/Pole.Sagas/Core/SagaFactory.cs
new file mode 100644
index 0000000..834de0b
--- /dev/null
+++ b/src/Pole.Sagas/Core/SagaFactory.cs
@@ -0,0 +1,24 @@
+using Pole.Core.Utils.Abstraction;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Core
+{
+ class SagaFactory : ISagaFactory
+ {
+ private readonly ISnowflakeIdGenerator _snowflakeIdGenerator;
+ public SagaFactory(ISnowflakeIdGenerator snowflakeIdGenerator)
+ {
+ _snowflakeIdGenerator = snowflakeIdGenerator;
+ }
+
+ public TSaga CreateSaga(TimeSpan timeOut) where TSaga : ISaga
+ {
+ var name = typeof(TSaga).FullName;
+ var SagaFlow = SagasCollection.Get(name);
+ var newId = _snowflakeIdGenerator.NextId();
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/Pole.Sagas/Core/SagasCollection.cs b/src/Pole.Sagas/Core/SagasCollection.cs
new file mode 100644
index 0000000..70b5aad
--- /dev/null
+++ b/src/Pole.Sagas/Core/SagasCollection.cs
@@ -0,0 +1,25 @@
+using Pole.Sagas.Core.Exceptions;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Core
+{
+ public class SagasCollection : Dictionary
+ {
+ private static System.Collections.Concurrent.ConcurrentDictionary _sagas = new System.Collections.Concurrent.ConcurrentDictionary();
+ public static ISaga Get(string name)
+ {
+ if (!_sagas.TryGetValue(name, out ISaga saga))
+ {
+ throw new SagaNotFoundException(name);
+ }
+ return saga;
+ }
+ public static bool Add(ISaga saga)
+ {
+ var name = saga.GetType().FullName;
+ return _sagas.TryAdd(name, saga);
+ }
+ }
+}
diff --git a/src/Pole.Sagas/Pole.Sagas.csproj b/src/Pole.Sagas/Pole.Sagas.csproj
new file mode 100644
index 0000000..167d5f2
--- /dev/null
+++ b/src/Pole.Sagas/Pole.Sagas.csproj
@@ -0,0 +1,16 @@
+
+
+
+ netstandard2.1
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Pole.Sagas/Server/Events/SagaStartedEvent.cs b/src/Pole.Sagas/Server/Events/SagaStartedEvent.cs
new file mode 100644
index 0000000..2f28f5a
--- /dev/null
+++ b/src/Pole.Sagas/Server/Events/SagaStartedEvent.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Server.Events
+{
+ class SagaStartedEvent:IEvent
+ {
+
+ }
+}
diff --git a/src/Pole.Sagas/Server/IEvent.cs b/src/Pole.Sagas/Server/IEvent.cs
new file mode 100644
index 0000000..0fc2d52
--- /dev/null
+++ b/src/Pole.Sagas/Server/IEvent.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Pole.Sagas.Server
+{
+ public interface IEvent
+ {
+
+ }
+}