using Quadarax.Foundation.Core.Business.Processor.Enums;
using Quadarax.Foundation.Core.Data;
using Quadarax.Foundation.Core.Object;

namespace Quadarax.Foundation.Core.Business.Processor.Task
{
    public interface ITaskItemData : ITaskIdentifier, ITimeTracked, IEquatable<ITaskItemData>
    {
        #region *** Properties ***
        /// <summary>
        /// Contains the affinity token which is used to identify owning/locking queue.
        /// </summary>
        IAffinityToken? AffinityToken { get; }
        /// <summary>
        /// External reference of the task.
        /// </summary>
        public string Reference { get; }
        /// <summary>
        /// Status of the task.
        /// </summary>
        public ProcessStatusEnum Status { get; }
        /// <summary>
        /// Assembly qualified name of the provider class responsible to process task.
        /// </summary>
        public string ProviderClass { get; }
        /// <summary>
        /// Task priority value (0-maximal, 255-minimal / default 100).
        /// </summary>
        public byte Priority { get; }
        /// <summary>
        /// Time when task can be processed.
        /// </summary>
        public DateTime ProcessingValidFrom { get; }
        /// <summary>
        /// Time when task will be expired.
        /// </summary>
        public DateTime? ProcessingValidTo { get; }
        /// <summary>
        /// Defines single attempt timeout. If null, timeout is not used.
        /// </summary>
        public TimeSpan? AttemptTimeout { get; }
        /// <summary>
        /// Decremental counter of attempts to try process task.
        /// </summary>
        public int AttemptsLeft { get; }
        /// <summary>
        /// Initial attempt count value
        /// </summary>
        public int InitialAttempts { get; }
        /// <summary>
        /// Statistical timestamp when task begins to process.
        /// </summary>
        public DateTime StatStarted { get; }
        /// <summary>
        /// Statistical timestamp when task finished.
        /// </summary>
        public DateTime StatFinished { get; }
        /// <summary>
        /// Latest attempt duration
        /// </summary>
        public TimeSpan StatLastAttemptDuration { get; }

        /// <summary>
        /// Collection of task status changes history log items. Ordered by <see cref="ITaskStatusLogItem.Created"/> descending.
        /// </summary>
        public ITaskStatusLogItem[] StatusLog { get; }

        /// <summary>
        /// Collection of task arguments.
        /// </summary>
        public ITypedArgument[] Arguments { get; }
        #endregion
    }
}
