DocSpace-buildtools/common/services/ASC.Webhooks.Service/BuildQueueService.cs

37 lines
906 B
C#
Raw Normal View History

2021-07-29 11:04:42 +00:00
using System.Collections.Concurrent;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Web.Webhooks;
2021-08-26 18:43:41 +00:00
namespace ASC.Webhooks.Service
{
[Singletone]
public class BuildQueueService
{
2021-08-27 14:50:49 +00:00
internal ConcurrentQueue<WebhookRequest> Queue { get; }
private ICacheNotify<WebhookRequest> WebhookNotify { get; }
2021-08-19 12:56:14 +00:00
public BuildQueueService(ICacheNotify<WebhookRequest> webhookNotify)
{
WebhookNotify = webhookNotify;
2021-08-03 16:26:28 +00:00
Queue = new ConcurrentQueue<WebhookRequest>();
}
public void Start()
{
WebhookNotify.Subscribe(BuildWebhooksQueue, CacheNotifyAction.Update);
}
public void Stop()
{
WebhookNotify.Unsubscribe(CacheNotifyAction.Update);
}
public void BuildWebhooksQueue(WebhookRequest request)
{
2021-08-03 16:26:28 +00:00
Queue.Enqueue(request);
}
}
}