SqlFlow Repository interface aangepast
This commit is contained in:
parent
1fc8bece0e
commit
d71927915c
@ -30,7 +30,7 @@ namespace Tapeti.Flow.SQL
|
||||
|
||||
public void RegisterDefaults(IDependencyContainer container)
|
||||
{
|
||||
container.RegisterDefault<IFlowRepository<Default.FlowState>>(() => new SqlConnectionFlowRepository<Default.FlowState>(connectionString, serviceId, schema));
|
||||
container.RegisterDefault<IFlowRepository>(() => new SqlConnectionFlowRepository(connectionString, serviceId, schema));
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace Tapeti.Flow.SQL
|
||||
);
|
||||
go;
|
||||
*/
|
||||
public class SqlConnectionFlowRepository<T> : IFlowRepository<T>
|
||||
public class SqlConnectionFlowRepository : IFlowRepository
|
||||
{
|
||||
private readonly string connectionString;
|
||||
private readonly int serviceId;
|
||||
@ -39,7 +39,7 @@ namespace Tapeti.Flow.SQL
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<KeyValuePair<Guid, T>>> GetStates()
|
||||
public async Task<List<KeyValuePair<Guid, T>>> GetStates<T>()
|
||||
{
|
||||
using (var connection = await GetConnection())
|
||||
{
|
||||
@ -69,14 +69,14 @@ namespace Tapeti.Flow.SQL
|
||||
|
||||
}
|
||||
|
||||
public Task CreateState(Guid flowID, T state, DateTime timestamp)
|
||||
public Task CreateState<T>(Guid flowID, T state, DateTime timestamp)
|
||||
{
|
||||
var stateJason = JsonConvert.SerializeObject(state);
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task UpdateState(Guid flowID, T state)
|
||||
public Task UpdateState<T>(Guid flowID, T state)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
public static class ConfigExtensions
|
||||
{
|
||||
public static TapetiConfig WithFlow(this TapetiConfig config, IFlowRepository<Default.FlowState> flowRepository = null)
|
||||
public static TapetiConfig WithFlow(this TapetiConfig config, IFlowRepository flowRepository = null)
|
||||
{
|
||||
config.Use(new FlowMiddleware(flowRepository));
|
||||
return config;
|
||||
|
@ -13,10 +13,10 @@ namespace Tapeti.Flow.Default
|
||||
private static readonly ConcurrentDictionary<Guid, FlowState> FlowStates = new ConcurrentDictionary<Guid, FlowState>();
|
||||
private static readonly ConcurrentDictionary<Guid, Guid> ContinuationLookup = new ConcurrentDictionary<Guid, Guid>();
|
||||
|
||||
private readonly IFlowRepository<FlowState> repository;
|
||||
private readonly IFlowRepository repository;
|
||||
|
||||
|
||||
public FlowStore(IFlowRepository<FlowState> repository)
|
||||
public FlowStore(IFlowRepository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
@ -27,7 +27,7 @@ namespace Tapeti.Flow.Default
|
||||
FlowStates.Clear();
|
||||
ContinuationLookup.Clear();
|
||||
|
||||
foreach (var flowStateRecord in await repository.GetStates())
|
||||
foreach (var flowStateRecord in await repository.GetStates<FlowState>())
|
||||
{
|
||||
FlowStates.TryAdd(flowStateRecord.Key, flowStateRecord.Value);
|
||||
|
||||
|
@ -5,19 +5,19 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Tapeti.Flow.Default
|
||||
{
|
||||
public class NonPersistentFlowRepository<T> : IFlowRepository<T>
|
||||
public class NonPersistentFlowRepository : IFlowRepository
|
||||
{
|
||||
Task<List<KeyValuePair<Guid, T>>> IFlowRepository<T>.GetStates()
|
||||
Task<List<KeyValuePair<Guid, T>>> IFlowRepository.GetStates<T>()
|
||||
{
|
||||
return Task.FromResult(new List<KeyValuePair<Guid, T>>());
|
||||
}
|
||||
|
||||
public Task CreateState(Guid flowID, T state, DateTime timestamp)
|
||||
public Task CreateState<T>(Guid flowID, T state, DateTime timestamp)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task UpdateState(Guid flowID, T state)
|
||||
public Task UpdateState<T>(Guid flowID, T state)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ namespace Tapeti.Flow
|
||||
{
|
||||
public class FlowMiddleware : ITapetiExtension
|
||||
{
|
||||
private IFlowRepository<Default.FlowState> flowRepository;
|
||||
private IFlowRepository flowRepository;
|
||||
|
||||
public FlowMiddleware(IFlowRepository<Default.FlowState> flowRepository)
|
||||
public FlowMiddleware(IFlowRepository flowRepository)
|
||||
{
|
||||
this.flowRepository = flowRepository;
|
||||
}
|
||||
@ -18,7 +18,7 @@ namespace Tapeti.Flow
|
||||
container.RegisterDefault<IFlowProvider, FlowProvider>();
|
||||
container.RegisterDefault<IFlowStarter, FlowStarter>();
|
||||
container.RegisterDefault<IFlowHandler, FlowProvider>();
|
||||
container.RegisterDefault<IFlowRepository<FlowState>>(() => flowRepository ?? new NonPersistentFlowRepository<Default.FlowState>());
|
||||
container.RegisterDefault<IFlowRepository>(() => flowRepository ?? new NonPersistentFlowRepository());
|
||||
container.RegisterDefault<IFlowStore, FlowStore>();
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Tapeti.Flow
|
||||
{
|
||||
public interface IFlowRepository<T>
|
||||
public interface IFlowRepository
|
||||
{
|
||||
Task<List<KeyValuePair<Guid, T>>> GetStates();
|
||||
Task CreateState(Guid flowID, T state, DateTime timestamp);
|
||||
Task UpdateState(Guid flowID, T state);
|
||||
Task<List<KeyValuePair<Guid, T>>> GetStates<T>();
|
||||
Task CreateState<T>(Guid flowID, T state, DateTime timestamp);
|
||||
Task UpdateState<T>(Guid flowID, T state);
|
||||
Task DeleteState(Guid flowID);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user