Пример #1
0
        public static IServiceCollection AddCallApi(this IServiceCollection services)
        {
            services.AddTransient <ClientSpanRepos>();
            services.AddTransient <CallApiFormCtrl>();
            services.AddTransient <CallApiForm>();

            //todo read from config
            var apiProxyConfig = new ApiProxyConfig();

            services.AddSingleton(apiProxyConfig);

            //IClientTracerApiProxy
            services.AddSingleton <IClientTracerApiProxy>(sp =>
            {
                var webApiHelper             = sp.GetService <IWebApiHelper>();
                var proxyConfig              = sp.GetService <ApiProxyConfig>();
                var httpClientTracerApiProxy = new HttpClientTracerApiProxy(webApiHelper, proxyConfig);
                var apiProxySmartWrapper     = ClientTracerApiProxySmartWrapper.Resolve();
                apiProxySmartWrapper.Reset(httpClientTracerApiProxy);

                return(apiProxySmartWrapper);
            });

            return(services);
        }
Пример #2
0
        public void SetUp()
        {
            messageHandler = new TestHttpHandler();
            messageHandler.NextResponse = new HttpResponseMessage(HttpStatusCode.NoContent);
            var httpClient = new HttpClient(messageHandler);

            proxyConfig = new ApiProxyConfig();
            var proxyConfigOpts = new Mock <IOptions <ApiProxyConfig> >();

            proxyConfigOpts.SetupGet(o => o.Value).Returns(proxyConfig);
            authBuilder = new Mock <IAuthenticationFactory>();
            subject     = new ApiProxyController(httpClient, proxyConfigOpts.Object, authBuilder.Object);
            subject.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
        }
Пример #3
0
        private static void SetupTraceApi()
        {
            //with api
            //todo read from config
            var apiProxyConfig = new ApiProxyConfig();

            //apiProxyConfig.BaseUri = "http://localhost:16685/api/trace";
            apiProxyConfig.BaseUri = "http://192.168.1.133:16685/api/trace";
            apiProxyConfig.FailTimeoutMilliseconds = 200;
            var webApiHelper = WebApiHelper.Resolve();

            var httpClientTracerApiProxy = new HttpClientTracerApiProxy(webApiHelper, apiProxyConfig);

            ApiProxyInit.Reset(httpClientTracerApiProxy, null, null);

            //var simpleIoc = SimpleIoc.Instance;

            //var knownCommands = KnownCommands.Instance;
            //knownCommands.Setup();
            //simpleIoc.Register(() => knownCommands);

            //var commandQueue = new CommandQueue();
            //simpleIoc.Register(() => commandQueue);

            //var commandQueueTask = new CommandQueueTask();
            //simpleIoc.Register(() => commandQueueTask);

            //var clientTracerApi = new ClientTracerApi(commandQueue);
            //simpleIoc.Register(() => clientTracerApi);
            //simpleIoc.Register(() =>
            //{
            //    var clientSpanProcesses = new List<IClientSpanProcess>();
            //    clientSpanProcesses.Add(new TraceSendProcess(new JaegerTraceSender()));
            //    clientSpanProcesses.Add(new TraceSaveProcess(new ClientSpanRepository(AsyncFile.Instance)));
            //    return clientSpanProcesses;
            //});

            ////without api
            //LocalClientTracerApiProxyConfig.Setup(clientTracerApi);
        }