public static async Task Main() { //await OldProfilingCode(); var random = new Random(0); GuidGenerator = new StubGuidGenerator(); const string uri = "http://localhost:9010/capture/product/bike/version/2.0/wip/5a7a2367593b3254c8ba1930"; var content = JObject.Parse(json); //for (var x = 0; x < 100; x++) while (true) { var waitTimeMs = random.Next(100, 3000); Thread.Sleep(waitTimeMs); var request = CreateRequest(uri, content, HttpMethod.Put); try { HttpResponseMessage responseMessage; responseMessage = await Client.SendAsync(request); Console.WriteLine(responseMessage?.StatusCode); } catch (Exception) { } } }
public async Task setup_scenario() { _currentRequestId = Guid.NewGuid().ToString(); _newRequestId = Guid.NewGuid().ToString(); _correlationId = Guid.NewGuid().ToString(); _sessionId = Guid.NewGuid().ToString(); _service = "my-service"; _version = "1.0.1-client"; var sessionIdAccessor = new StubSessionIdAccessor { Response = _sessionId }; var correlationIdAccessor = new StubCorrelationIdAccessor { Response = _correlationId }; var outboundRequestIdAccessor = new StubOutboundRequestIdAccessor { OutboundRequestId = _currentRequestId }; var guidGenerator = new StubGuidGenerator(Guid.Parse(_newRequestId)); var applicationInfo = new StubApplicationInfo { Name = _service, Version = _version, OperatingSystem = "my-os" }; using (var webApi = new GetIdsFromHeadersHttpApi()) using (var httpClient = webApi.CreateClientWithTagging(sessionIdAccessor, correlationIdAccessor, outboundRequestIdAccessor, guidGenerator, applicationInfo)) { var response = await httpClient.GetAsync("/get-ids-from-headers"); var content = await response.Content.ReadAsStringAsync(); _idsFromHeaders = JObject.Parse(content); } }
public async Task setup_scenario() { StubGuidGenerator.Add(RequestId, CorrelationId); var response = await TestHost.GetAsync("/get-ids-from-context"); var content = await response.Content.ReadAsStringAsync(); _ids = JObject.Parse(content); }
public void setup_scenario_base() { StubGuidGenerator = new StubGuidGenerator(); RequestId = Guid.NewGuid(); CorrelationId = Guid.NewGuid(); SessionId = Guid.NewGuid(); StubHttpServerEventCallback = new StubHttpServerEventCallback(); TestHost = new LightweightHttpApiHost(services => { services.AddDefaultServices(); services.AddSingleton <ICircuitBreakerManager, StubCircuitBreakerManager>(); services.AddSingleton <IGenerateGuids>(StubGuidGenerator); services.AddSingleton <IHttpServerEventCallback>(CreateIdentifyingCallback); services.AddSingleton <IHttpServerEventCallback>(StubHttpServerEventCallback); }, Configure); }
public async Task setup_scenario() { var sessionIdAccessor = new StubSessionIdAccessor(); var correlationIdAccessor = new StubCorrelationIdAccessor(); var outboundRequestIdAccessor = new StubOutboundRequestIdAccessor(); var guidGenerator = new StubGuidGenerator(Guid.NewGuid()); var applicationInfo = new StubApplicationInfo { Name = "my-service", Version = "1.1.2", Environment = "Staging", OperatingSystem = "my-os" }; using (var webApi = new GetIdsFromHeadersHttpApi()) using (var httpClient = webApi.CreateClientWithTagging(sessionIdAccessor, correlationIdAccessor, outboundRequestIdAccessor, guidGenerator, applicationInfo)) { var response = await httpClient.GetAsync("/get-ids-from-headers"); var content = await response.Content.ReadAsStringAsync(); _idsFromHeaders = JObject.Parse(content); } }