Exemplo n.º 1
0
        private static List <Task <long> > CreateProxyTasks(IServiceProxyClient <IDog> dogProxyClient, Dictionary <string, string> headers, int count)
        {
            var globalInterceptors = CreateGlobalInterceptors();
            var proxyCallTasks     = new List <Task <long> >();

            for (int i = 0; i < count; i++)
            {
                proxyCallTasks.Add(ExecuteProxyClient(dogProxyClient, headers, globalInterceptors));
            }

            return(proxyCallTasks);
        }
Exemplo n.º 2
0
 private static Task <long> ExecuteProxyClient(IServiceProxyClient <IDog> dogProxyClient, Dictionary <string, string> headers, IOrderedEnumerable <IProxyInterceptor> globalInterceptors)
 {
     return(Task.Run(async() =>
     {
         var dog = dogProxyClient.GetService(headers, globalInterceptors);
         Stopwatch st = new Stopwatch();
         st.Start();
         var name = await dog.Bark(new DogService.Models.BarkRequest
         {
             Name = "thor"
         });
         st.Stop();
         return st.ElapsedMilliseconds;
     }));
 }
Exemplo n.º 3
0
        private static void Preconditions(out IServiceProxyClient <IDog> dogProxyClient, out Dictionary <string, string> headers)
        {
            var collection = new ServiceCollection()
                             .AddScoped <ISerializer, JsonNetSerializer>()
                             .AddScoped((IServiceProvider p) =>
            {
                return(new ServiceInformation <IDog>
                {
                    BaseUrl = "https://localhost:5001/api/",
                    Ttl = TimeSpan.FromSeconds(30)
                });
            })
                             .AddSimpleProxyClient <IDog>()
                             .BuildServiceProvider();

            dogProxyClient = collection.GetService <IServiceProxyClient <IDog> >();
            headers        = new Dictionary <string, string>
            {
                { "color", "blue" }
            };
        }
Exemplo n.º 4
0
 public LoginController(IServiceProxyClient proxy)
 {
     this.proxy = proxy;
 }