PsQueue.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using qdr.fnd.core.pqueue.Configuration;
  2. using qdr.fnd.core.pqueue.Enums;
  3. using qdr.fnd.core.pqueue.Process;
  4. using qdr.fnd.core.pqueue.Storages;
  5. using Quadarax.Foundation.Core.Data;
  6. using Quadarax.Foundation.Core.Logging;
  7. using Quadarax.Foundation.Core.Object;
  8. using Quadarax.Foundation.Core.Value.Generators;
  9. namespace qdr.fnd.core.pqueue
  10. {
  11. public class PsQueue : DisposableObject
  12. {
  13. #region *** Properties ***
  14. public string Name { get; }
  15. public bool IsRunning { get; private set; }
  16. public PsQueueConfiguration Configuration { get;}
  17. public event PsQueueStatusChangedEventHandler? ProcessItemStatusChanged;
  18. #endregion
  19. #region *** Private Fields ***
  20. private ILog _log;
  21. private TinyHash _hashGenerator;
  22. protected IPsQueueStorage? _storage;
  23. #endregion
  24. #region *** Constructors ***
  25. public PsQueue(string queueName, PsQueueConfiguration configuration,IPsQueueStorage storageProvider, ILogger logger)
  26. {
  27. _hashGenerator = new TinyHash(5);
  28. if (string.IsNullOrEmpty(queueName))
  29. queueName = "PSQUEUE" + _hashGenerator.NewId();
  30. Name = queueName;
  31. IsRunning = false;
  32. Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
  33. _storage = storageProvider ?? throw new ArgumentNullException(nameof(storageProvider));
  34. _log = logger.GetLogger(queueName);
  35. }
  36. #endregion
  37. #region *** Public Operations ***
  38. public void Start()
  39. {
  40. //TODO: Implement Start
  41. }
  42. public void Stop()
  43. {
  44. //TODO: Implement Stop
  45. }
  46. public IPsQueueItem Queue(string owner, string ownerRef, IPsProcessProvider provider, IEnumerable<ITypedArgument> arguments, int priority,int initialAttepts, DateTime validFrom, DateTime? validTo)
  47. {
  48. }
  49. public IPsQueueItem Queue(string owner, string ownerRef, IPsProcessProvider provider, IEnumerable<ITypedArgument> arguments, int priority,int initialAttepts)
  50. {
  51. }
  52. public IPsQueueItem Queue(string owner, string ownerRef, IPsProcessProvider provider, IEnumerable<ITypedArgument> arguments)
  53. {
  54. }
  55. public bool Dequeue(string itemId, bool force)
  56. {
  57. }
  58. public IQueryable<IPsQueueItem> Query(string? owner, string? ownerRef, params Tuple<bool,PsStatusEnum>[] status)
  59. {
  60. }
  61. public IPsQueueItem? Get(string itemId)
  62. {
  63. }
  64. public bool Postpone(string itemId, TimeSpan postpone)
  65. {
  66. }
  67. public bool Reset(string itemId)
  68. {
  69. }
  70. public bool SetPriority(string itemId, int priority)
  71. {
  72. }
  73. public IEnumerable<IPsQueueItem> GetWorkingItems()
  74. {
  75. }
  76. #endregion
  77. #region *** Private Operations ***
  78. protected override void OnDisposing()
  79. {
  80. if(IsRunning)
  81. Stop();
  82. ProcessItemStatusChanged = null;
  83. _storage = null;
  84. //TODO: Implement OnDisposing
  85. }
  86. #endregion
  87. }
  88. }