コード例 #1
0
        /// <summary>
        /// Publish a single request using the KubeMQ , response will return in the passed handler.
        /// </summary>
        /// <param name="handler">Method that will be activated once receiving response.</param>
        /// <param name="request">The KubeMQ.SDK.csharp.RequestReply.LowLevel.request that will be sent to the kubeMQ.</param>
        /// <returns>A task that represents the request that was sent using the SendRequest.</returns>
        public async Task SendRequest(Request request, HandleResponseDelegate handler)
        {
            try
            {
                //LogRequest(request);

                InnerRequest innerRequest = request.Convert();

                // Send request and wait for response
                InnerResponse innerResponse = await GetKubeMQClient().SendRequestAsync(innerRequest, Metadata);

                // convert InnerResponse to Response and return response to end user
                Response response = new Response(innerResponse);

                // send the response to the end-user response handler
                handler(response);
            }
            catch (RpcException ex)
            {
                logger.LogError($"Grpc Exception in SendRequest. Status: {ex.Status}");

                throw new RpcException(ex.Status);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Exception in Initiator.SendRequest");

                throw ex;
            }
        }
コード例 #2
0
ファイル: Initiator.cs プロジェクト: TradencyDev/WarpTest
        public async void SendRequest(HandleResponseDelegate handler, Request request, string clientDisplayName = "")
        {
            try
            {
                //LogRequest(request);

                Metadata metadata = null;
                if (string.IsNullOrWhiteSpace(clientDisplayName))
                {
                    metadata = new Metadata {
                        { "client_tag", clientDisplayName }
                    };
                }

                InnerRequest innerRequest = request.Convert();

                // Send request and wait for response
                InnerResponse innerResponse = await GetWarpGrpcClient().SendRequestAsync(innerRequest, metadata);

                // convert InnerResponse to Response and return response to end user
                Response response = new Response(innerResponse);

                // send the response to the end-user response handler
                handler(response);
            }
            catch (RpcException ex)
            {
                logger.LogError($"Grpc Exception in SendRequest. Status: {ex.Status}");

                throw new RpcException(ex.Status);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Exception in Initiator.SendRequest");

                throw ex;
            }
        }
コード例 #3
0
 /// <summary>
 /// Publish a single request using the KubeMQ , response will return in the passed handler.
 /// </summary>
 /// <param name="request">The KubeMQ.SDK.csharp.RequestReply.LowLevel.request that will be sent to the kubeMQ.</param>
 /// <param name="handler">Method that will be activated once receiving response.</param>
 /// <param name="overrideParams">Optional - allow overwriting "Timeout" "CacheKey" and "CacheTTL" for a single Request.</param>
 /// <returns>A task that represents the request that was sent using the SendRequest .</returns>
 public async Task SendRequest(Request request, HandleResponseDelegate handler, RequestParameters overrideParams = null)
 {
     await _initiator.SendRequest(CreateLowLevelRequest (request, overrideParams), handler);
 }