using System.Collections.Immutable; using Connected.Collections; using Connected.Collections.Queues; using Connected.Net; using Connected.ServiceModel; using Connected.Services; using Ops = Common.Collections.QueueOps; namespace Common.Collections; internal sealed class QueueService : DistributedService, IQueueService { public QueueService(IContext context) : base(context) { } public async Task> Dequeue(DequeueArgs args) { if (await IsServer()) return await Invoke(GetOperation(), args) ?? ImmutableList.Empty; if (await Http.Get>(await ParseUrl(CollectionRoutes.Queue), args) is List result) return result.ToImmutableList(); return ImmutableList.Empty; } public async Task Enqueue(TArgs args) where TClient : IQueueClient where TArgs : QueueArgs { if (await IsServer()) { await Invoke(GetOperation>(), args); return; } await Http.Post>(await ParseUrl(CollectionRoutes.Queue), new object[] { typeof(TClient), args }); } }