using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Tapeti.Flow { /// /// Provides persistency for flow states. /// public interface IFlowRepository { /// /// Load the previously persisted flow states. /// /// A list of flow states, where the key is the unique Flow ID and the value is the deserialized T. ValueTask>> GetStates(); /// /// Stores a new flow state. Guaranteed to be run in a lock for the specified flow ID. /// /// The unique ID of the flow. /// The flow state to be stored. /// The time when the flow was initially created. /// ValueTask CreateState(Guid flowID, T state, DateTime timestamp); /// /// Updates an existing flow state. Guaranteed to be run in a lock for the specified flow ID. /// /// The unique ID of the flow. /// The flow state to be stored. ValueTask UpdateState(Guid flowID, T state); /// /// Delete a flow state. Guaranteed to be run in a lock for the specified flow ID. /// /// The unique ID of the flow. ValueTask DeleteState(Guid flowID); } /// /// Contains information about a persisted flow state. /// public class FlowRecord { /// /// The unique ID of the flow. /// public Guid FlowID { get; } /// /// The time when the flow was initially created. /// public DateTime CreationTime { get; } /// /// The stored flow state. /// public T FlowState { get; } /// /// Creates a new instance of a FlowRecord. /// /// /// /// public FlowRecord(Guid flowID, DateTime creationTime, T flowState) { FlowID = flowID; CreationTime = creationTime; FlowState = flowState; } } }