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.
///
ValueTask Load();
///
/// Looks up the FlowID corresponding to a ContinuationID. For internal use.
///
///
ValueTask FindFlowID(Guid continuationID);
///
/// Acquires a lock on the flow with the specified FlowID.
///
///
ValueTask 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.
ValueTask> 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.
///
ValueTask GetFlowState();
///
/// Stores the new flow state.
///
///
///
ValueTask StoreFlowState(FlowState flowState, bool persistent);
///
/// Disposes of the flow state corresponding to this Flow ID.
///
ValueTask 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;
}
}
}