public override async Task <Task> ProcessInScope(IServiceProvider serviceProvider) { Console.WriteLine("Processing starts here"); _context = serviceProvider.GetService <HavokContext>(); Havok item = _context.Havoks.First(); if (item.resourceGroupName != null) { AzureAppService apps = await GetAzureAppService(); if (apps.properties.numberOfWorkers > 1) { item.isScaledOut = true; } else { item.isScaledOut = false; } _context.Entry(item).State = EntityState.Modified; _context.SaveChanges(); } return(Task.CompletedTask); }
public async Task Invoke(HttpContext httpContext, HavokContext context) { int delayInMs = _random.Value.Next(_minDelayInMs, _maxDelayInMs); var myEnt = context.Havoks.First(); if (myEnt.HavokEnabled == true && myEnt.isScaledOut == false) { await Task.Delay(delayInMs); } await _next(httpContext); }
public HavokController(HavokContext context) { _context = context; }