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

37 lines
904 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;
namespace ASC.Webhooks
{
[Singletone]
public class BuildQueueService
{
2021-08-03 16:26:28 +00:00
internal ConcurrentQueue<WebhookRequest> Queue { get; }
2021-07-29 11:04:42 +00:00
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);
}
}
}