using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Tapeti.Flow.Default;
// ReSharper disable UnusedMember.Global
namespace Tapeti.Flow
{
///
/// Provides a way to store and load flow state.
///
public interface IFlowStore
{
///
/// Must be called during application startup before subscribing or starting a flow.
/// If using an IFlowRepository that requires an update (such as creating tables) make
/// sure it is called before calling Load.
///
Task Load();
///
/// Looks up the FlowID corresponding to a ContinuationID. For internal use.
///
///
Task FindFlowID(Guid continuationID);
///
/// Acquires a lock on the flow with the specified FlowID.
///
///
Task LockFlowState(Guid flowID);
///
/// Returns information about the currently active flows.
///
///
/// This is intended for monitoring purposes and should be treated as a snapshot.
///
/// The minimum age of the flow before it is included in the result. Set to TimeSpan.Zero to return all active flows.
Task> GetActiveFlows(TimeSpan minimumAge);
}
///
///
/// Represents a lock on the flow state, to provide thread safety.
///
public interface IFlowStateLock : IDisposable
{
///
/// The unique ID of the flow state.
///
Guid FlowID { get; }
///
/// Acquires a copy of the flow state.
///
Task GetFlowState();
///
/// Stores the new flow state.
///
///
///
Task StoreFlowState(FlowState flowState, bool persistent);
///
/// Disposes of the flow state corresponding to this Flow ID.
///
Task DeleteFlowState();
}
///
/// Contains information about an active flow, as returned by .
///
public class ActiveFlow
{
///
/// The ID of the active flow.
///
public Guid FlowID { get; }
///
/// The time when the flow was initially created.
///
public DateTime CreationTime { get; }
///
/// Create a new instance of an ActiveFlow.
///
/// The ID of the active flow.
/// The time when the flow was initially created.
public ActiveFlow(Guid flowID, DateTime creationTime)
{
FlowID = flowID;
CreationTime = creationTime;
}
}
}