1
0
mirror of synced 2024-11-21 17:03:50 +00:00

SqlFlow Repository interface aangepast

This commit is contained in:
Menno van Lavieren 2017-08-14 13:58:01 +02:00
parent 1fc8bece0e
commit d71927915c
7 changed files with 20 additions and 20 deletions

View File

@ -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));
}

View File

@ -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();
}

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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>();
}

View File

@ -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);
}