Ejemplo n.º 1
0
        private static async Task RunClientAsync(Tuple <Protocol, TProtocol> protocolTuple, CancellationToken cancellationToken)
        {
            try
            {
                var protocol     = protocolTuple.Item2;
                var protocolType = protocolTuple.Item1;

                TBaseClient client = null;

                try
                {
                    if (protocolType != Protocol.Multiplexed)
                    {
                        client = new Calculator.Client(protocol);

                        //await ExecuteCalculatorClientOperations(cancellationToken, (Calculator.Client)client);
                        await ExecuteCalculatorClientTest(cancellationToken, (Calculator.Client) client);

                        //Stopwatch sw2 = Stopwatch.StartNew();
                        //for (int i = 0; i < 10; i++)
                        //{
                        //    await ExecuteCalculatorClientTest(cancellationToken, (Calculator.Client)client);
                        //}
                        //sw2.Stop();
                        //long ms = sw2.ElapsedMilliseconds;
                        //Logger.LogInformation($"RunClientAsync 10 do:10 ms:{sw2.ElapsedMilliseconds}");
                    }
                    else
                    {
                        var multiplex = new TMultiplexedProtocol(protocol, nameof(Calculator));
                        client = new Calculator.Client(multiplex);
                        await ExecuteCalculatorClientOperations(cancellationToken, (Calculator.Client) client);

                        multiplex = new TMultiplexedProtocol(protocol, nameof(SharedService));
                        client    = new SharedService.Client(multiplex);

                        await ExecuteSharedServiceClientOperations(cancellationToken, (SharedService.Client) client);

                        //await ExecuteCalculatorClientOperations(cancellationToken, (Calculator.Client)client);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex, $"{client?.ClientId}" + ex);
                }
                finally
                {
                    protocol.Transport.Close();
                    Logger.LogInformation($"finally");
                }
            }
            catch (TApplicationException x)
            {
                Logger.LogError(x, x.ToString());
            }
        }
Ejemplo n.º 2
0
        private static async Task RunClientAsync(Tuple <Protocol, TProtocol> protocolTuple, CancellationToken cancellationToken)
        {
            try
            {
                var protocol     = protocolTuple.Item2;
                var protocolType = protocolTuple.Item1;

                TBaseClient client = null;

                try
                {
                    if (protocolType != Protocol.Multiplexed)
                    {
                        client = new Calculator.Client(protocol);
                        await ExecuteCalculatorClientOperations(cancellationToken, (Calculator.Client) client);
                    }
                    else
                    {
                        // it uses binary protocol there  to create Multiplexed protocols
                        var multiplex = new TMultiplexedProtocol(protocol, nameof(Calculator));
                        client = new Calculator.Client(multiplex);
                        await ExecuteCalculatorClientOperations(cancellationToken, (Calculator.Client) client);

                        multiplex = new TMultiplexedProtocol(protocol, nameof(SharedService));
                        client    = new SharedService.Client(multiplex);
                        await ExecuteSharedServiceClientOperations(cancellationToken, (SharedService.Client) client);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError($"{client?.ClientId} " + ex);
                }
                finally
                {
                    protocol.Transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Logger.LogError(x.ToString());
            }
        }
Ejemplo n.º 3
0
 public ThriftInvoker(TBaseClient instance, int clientTimeout)
 {
     _instance      = instance;
     _clientTimeout = clientTimeout;
 }
Ejemplo n.º 4
0
 public ThriftClient(TBaseClient thriftclient, int clientTimeout, URL url)
 {
     _thriftclient  = thriftclient;
     _clientTimeout = clientTimeout;
     this.Url       = url;
 }