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

36 lines
903 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-07-29 11:04:42 +00:00
internal readonly ConcurrentQueue<WebhookRequest> queue;
private ICacheNotify<WebhookRequest> WebhookNotify { get; }
public BuildQueueService(ICacheNotify<WebhookRequest> webhookNotify)
{
WebhookNotify = webhookNotify;
2021-07-29 11:04:42 +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-07-29 11:04:42 +00:00
queue.Enqueue(request);
}
}
}