using qdr.fnd.core.pqueue.Enums;
using Quadarax.Foundation.Core.Data;

namespace qdr.fnd.core.pqueue
{
    /// <summary>
    /// Interface for the queue item.
    /// </summary>
    public interface IPsQueueItem : IPsQueueItemDescriptor
    {
        #region *** Properties ***
        /// <summary>
        /// Unique identifier of the queue item.
        /// </summary>
        string Id { get; }
        
        /// <summary>
        /// Date and time when the queue item was created.
        /// </summary>
        DateTime Created { get; }
        /// <summary>
        /// Date and time when the queue item was started to process (last cycle).
        /// </summary>
        DateTime? Started { get; }
        /// <summary>
        /// Date and time when the queue item was finished to process (last cycle).
        /// </summary>
        DateTime? Finished { get; }
        /// <summary>
        /// Process item current status. Changes are logged in <see cref="StatusJournal"/>.
        /// </summary>
        PsStatusEnum Status { get; }

        /// <summary>
        /// Defines if <see cref="Status"/> is transient state. Changes are logged in <see cref="StatusJournal"/>.
        /// </summary>
        bool IsStatusTransient { get; }
        /// <summary>
        /// Defines current number of attempts left to process the queue item.
        /// </summary>
        int AttemptsLeft { get; }
        
        /// <summary>
        /// Collection of messages, errors, warnings logged during the process.
        /// </summary>
        IEnumerable<IError> Log { get; }
        /// <summary>
        /// Collection of status changes of the queue item. When <see cref="Status"/> or <see cref="IsStatusTransient"/> is changed, the status change is logged.
        /// </summary>
        IEnumerable<PsStatusHistory> StatusJournal { get;}
        #endregion
    }
}
