using System.Collections.Concurrent; using ASC.Common; using ASC.Common.Caching; using ASC.Web.Webhooks; namespace ASC.Webhooks.Service { [Singletone] public class BuildQueueService { internal ConcurrentQueue Queue { get; } private ICacheNotify WebhookNotify { get; } public BuildQueueService(ICacheNotify webhookNotify) { WebhookNotify = webhookNotify; Queue = new ConcurrentQueue(); } public void Start() { WebhookNotify.Subscribe(BuildWebhooksQueue, CacheNotifyAction.Update); } public void Stop() { WebhookNotify.Unsubscribe(CacheNotifyAction.Update); } public void BuildWebhooksQueue(WebhookRequest request) { Queue.Enqueue(request); } } }