コード例 #1
0
ファイル: QueueImpl.cs プロジェクト: ahives/HareDu1
        public async Task <Result> Sync(string queue, string vhost, QueueSyncAction syncAction, CancellationToken cancellationToken = default)
        {
            cancellationToken.RequestCanceled();

            QueueSyncRequest request = new QueueSyncRequest(syncAction);

            Debug.Assert(request != null);

            var errors = new List <Error>();

            if (string.IsNullOrWhiteSpace(vhost))
            {
                errors.Add(new ErrorImpl("The name of the virtual host is missing."));
            }

            if (string.IsNullOrWhiteSpace(queue))
            {
                errors.Add(new ErrorImpl("The name of the queue is missing."));
            }

            string url = $"api/queues/{vhost.ToSanitizedName()}/{queue}/actions";

            if (errors.Any())
            {
                return(new FaultedResult <QueueInfo>(new DebugInfoImpl(url, errors)));
            }

            return(await PostRequest(url, request, cancellationToken).ConfigureAwait(false));
        }
コード例 #2
0
        public async Task Verify_can_sync_queue3()
        {
            var services = GetContainerBuilder().BuildServiceProvider();
            var result   = await services.GetService <IBrokerObjectFactory>()
                           .CancelQueueSync("Queue1", "HareDu");

            Assert.Multiple(() =>
            {
                Assert.IsFalse(result.HasFaulted);
                Assert.IsNotNull(result.DebugInfo);

                QueueSyncRequest request = result.DebugInfo.Request.ToObject <QueueSyncRequest>();

                Assert.AreEqual(QueueSyncAction.CancelSync, request.Action);
            });
        }