ITaskItem.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Quadarax.Foundation.Core.Business.Processor.Enums;
  2. namespace Quadarax.Foundation.Core.Business.Processor.Task;
  3. public interface ITaskItem : ITaskIdentifier, ITimeTracked
  4. {
  5. #region *** Properties ***
  6. /// <summary>
  7. /// Contains the affinity token which is used to identify owning/locking queue.
  8. /// </summary>
  9. IAffinityToken AffinityToken { get; }
  10. /// <summary>
  11. /// External reference of the task.
  12. /// </summary>
  13. public string Reference { get; }
  14. /// <summary>
  15. /// Status of the task.
  16. /// </summary>
  17. public ProcessStatusEnum Status { get; }
  18. /// <summary>
  19. /// Assembly qualified name of the provider class responsible to process task.
  20. /// </summary>
  21. public string ProviderClass { get; }
  22. /// <summary>
  23. /// Task priority value (0-maximal, 255-minimal / default 100).
  24. /// </summary>
  25. public byte Priority { get; }
  26. /// <summary>
  27. /// Time when task can be processed.
  28. /// </summary>
  29. public DateTime ProcessingValidFrom { get; }
  30. /// <summary>
  31. /// Time when task will be expired.
  32. /// </summary>
  33. public DateTime? ProcessingValidTo { get; }
  34. /// <summary>
  35. /// Decremental counter of attempts to try process task.
  36. /// </summary>
  37. public int AttemptsLeft { get; }
  38. /// <summary>
  39. /// Statistical timestamp when task begins to process.
  40. /// </summary>
  41. public DateTime StatStarted { get; }
  42. /// <summary>
  43. /// Statistical timestamp when task finished.
  44. /// </summary>
  45. public DateTime StatFinished { get; }
  46. /// <summary>
  47. /// Latest attempt duration
  48. /// </summary>
  49. public TimeSpan StatLastAttemptDuration { get; }
  50. #endregion
  51. #region *** Operations ***
  52. /// <summary>
  53. /// Schedules task to future and sets <see cref="Status"/> to <see cref="ProcessStatusEnum.Pending"/> (affects <see cref="ProcessingValidFrom"/> and <see cref="ProcessingValidTo"/>).
  54. /// <list type="bullet">
  55. /// <item><description>Allowed state: <see cref="ProcessStatusEnum.Pending"/>, <see cref="ProcessStatusEnum.Paused"/></description></item>
  56. /// <item><description>Set state to: <see cref="ProcessStatusEnum.Pending"/></description></item>
  57. /// </list>
  58. /// </summary>
  59. /// <param name="postponeInterval">Interval to shift to future.</param>
  60. /// <param name="reason">Reason message to postpone.</param>
  61. void Postpone(TimeSpan postponeInterval, string reason);
  62. void Stop(string reason);
  63. void Reset(string reason);
  64. #endregion
  65. }