public Task PullResponses(CloudQueueCmdDto cmdObj)
        {
            cmdObj.GetUnpacker().UnpackString(out var action).Unpack <long>(out var position).UnpackInt(out int count).UnpackString(out string clientId);
            var res = this.instance.PullResponses(action, (GetResponsePosition)position, count, clientId);

            return(this.CreateAndSendResponse(cmdObj, res));
        }
        public Task PingBroker2(CloudQueueCmdDto cmdObj)
        {
            cmdObj.GetUnpacker().UnpackString(out var id);
            var res = this.instance.PingBroker2(id);

            return(this.CreateAndSendResponse(cmdObj.RequestId, cmdObj.CmdName, res));
        }
        public Task CreateDurable(CloudQueueCmdDto cmdObj)
        {
            cmdObj.GetUnpacker().Unpack <SessionStartInfoContract>(out var info).UnpackString(out var id);
            var res = this.instance.CreateDurable(info, id);

            return(this.CreateAndSendResponse(cmdObj.RequestId, cmdObj.CmdName, res));
        }
        public Task GetRequestsCount(CloudQueueCmdDto cmdObj)
        {
            cmdObj.GetUnpacker().UnpackString(out var clientId);
            var res = this.instance.GetRequestsCount(clientId);

            return(this.CreateAndSendResponse(cmdObj, res));
        }
예제 #5
0
        protected async Task <object> StartRequestAsync(string cmdName, params object[] parameter)
        {
            CloudQueueCmdDto cmd = new CloudQueueCmdDto(cmdName, parameter);

            await this.Writer.WriteAsync(cmd);

            TaskCompletionSource <object> tsc = new TaskCompletionSource <object>();

            this.requestTrackDictionary.TryAdd(cmd.RequestId, tsc);
            return(await tsc.Task);
        }
        public Task GetResponsesAQ(CloudQueueCmdDto cmdObj)
        {
            cmdObj.GetUnpacker()
            .UnpackString(out string action)
            .UnpackString(out string clientData)
            .Unpack <long>(out var resetToBegin)
            .UnpackInt(out int count)
            .UnpackString(out string clientId)
            .UnpackInt(out var sessionHash);
            this.instance.GetResponsesAQ(action, clientData, (GetResponsePosition)resetToBegin, count, clientId, sessionHash, out var azureResponseQueueUri, out var azureResponseBlobUri);
            var res = (azureResponseQueueUri, azureResponseBlobUri);

            return(this.CreateAndSendResponse(cmdObj, res));
        }
예제 #7
0
        public void BasicRequestSerializeE2E()
        {
            var serializer = new CloudQueueSerializer(CloudQueueCmdTypeBinder.BrokerLauncherBinder);
            var cmd        = new CloudQueueCmdDto("TestId", "TestCmd", new SessionStartInfoContract(), 10);
            var str        = serializer.Serialize(cmd);
            var dcmd       = serializer.Deserialize <CloudQueueCmdDto>(str);

            Assert.AreEqual(cmd.RequestId, dcmd.RequestId);
            Assert.AreEqual(cmd.CmdName, dcmd.CmdName);
            Assert.AreEqual(cmd.Version, dcmd.Version);
            Assert.AreEqual(cmd.Parameters.Length, dcmd.Parameters.Length);

            Assert.AreEqual(cmd.Parameters[0].GetType(), dcmd.Parameters[0].GetType());
            Assert.AreEqual(typeof(long), dcmd.Parameters[1].GetType());
        }
예제 #8
0
        protected async Task InvokeInstanceMethodFromCmdObj(CloudQueueCmdDto cmdObj)
        {
            if (cmdObj == null)
            {
                throw new ArgumentNullException(nameof(cmdObj));
            }

            if (string.IsNullOrEmpty(cmdObj.CmdName))
            {
                throw new InvalidOperationException($"{nameof(cmdObj.CmdName)} is null or empty string.");
            }

            if (this.cmdNameToDelegate.TryGetValue(cmdObj.CmdName, out var del))
            {
                await del(cmdObj);
            }
            else
            {
                throw new InvalidOperationException($"Unknown CmdName {cmdObj.CmdName}");
            }
        }
 public Task Close(CloudQueueCmdDto cmdObj)
 {
     cmdObj.GetUnpacker().UnpackString(out var id);
     this.instance.Close(id);
     return(this.CreateAndSendResponse(cmdObj.RequestId, cmdObj.CmdName, string.Empty));
 }
        public Task GetActiveBrokerIdList(CloudQueueCmdDto cmdObj)
        {
            var res = this.instance.GetActiveBrokerIdList();

            return(this.CreateAndSendResponse(cmdObj.RequestId, cmdObj.CmdName, res));
        }
 public Task Purge(CloudQueueCmdDto cmdObj)
 {
     cmdObj.GetUnpacker().UnpackString(out var clientid);
     this.instance.Purge(clientid);
     return(this.CreateAndSendEmptyResponse(cmdObj));
 }
 public Task EndRequests(CloudQueueCmdDto cmdObj)
 {
     cmdObj.GetUnpacker().UnpackInt(out var count).UnpackString(out string clientid).UnpackInt(out int batchId).UnpackInt(out int timeoutThrottlingMs).UnpackInt(out int timeoutEOMMs);
     this.instance.EndRequests(count, clientid, batchId, timeoutThrottlingMs, timeoutEOMMs);
     return(this.CreateAndSendEmptyResponse(cmdObj));
 }
 public Task Ping(CloudQueueCmdDto cmdObj)
 {
     this.instance.Ping();
     return(this.CreateAndSendEmptyResponse(cmdObj));
 }
예제 #14
0
 public static ParameterUnpacker GetUnpacker(this CloudQueueCmdDto dto)
 {
     return(new ParameterUnpacker(dto.Parameters));
 }
예제 #15
0
 protected Task CreateAndSendEmptyResponse(CloudQueueCmdDto cmdObj)
 {
     return(this.CreateAndSendResponse(cmdObj.RequestId, cmdObj.CmdName, string.Empty));
 }
예제 #16
0
 protected Task CreateAndSendResponse(CloudQueueCmdDto cmdObj, object response)
 {
     return(this.CreateAndSendResponse(cmdObj.RequestId, cmdObj.CmdName, response));
 }