Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chervet committed Jun 26, 2023
1 parent d99bb7d commit 003fde4
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/SlimFaas/SlimProxyMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,7 @@ public async Task InvokeAsync(HttpContext context, ILogger<SlimProxyMiddleware>
contextResponse.StatusCode = 200;
return;
case FunctionType.Sync:

var numerLoop = 100;
while (numerLoop > 0)
{
if(replicasService.Deployments.Functions.Count(f => f.Replicas.HasValue && f.Replicas.Value > 0 && f.Pods.Count(p => p.Ready.HasValue && p.Ready.Value ) <= 0) <= 0 )
{
numerLoop--;
await Task.Delay(200);
continue;
}
numerLoop=0;
}

await BuildSyncResponse(context, historyHttpService, sendClient, functionName, functionPath);
await BuildSyncResponse(context, historyHttpService, sendClient, replicasService, functionName, functionPath);
return;
case FunctionType.Async:
default:
Expand All @@ -70,9 +57,20 @@ await _queue.EnqueueAsync(functionName,
}

private async Task BuildSyncResponse(HttpContext context, HistoryHttpMemoryService historyHttpService,
ISendClient sendClient, string functionName, string functionPath)
ISendClient sendClient, IReplicasService replicasService, string functionName, string functionPath)
{
historyHttpService.SetTickLastCall(functionName, DateTime.Now.Ticks);
var numerLoop = 100;
while (numerLoop > 0)
{
if(replicasService.Deployments.Functions.Count(f => f.Replicas.HasValue && f.Replicas.Value > 0 && f.Pods.Count(p => p.Ready.HasValue && p.Ready.Value ) > 0) <= 0 )
{
numerLoop--;
await Task.Delay(200);
continue;
}
numerLoop=0;
}

var responseMessagePromise = sendClient.SendHttpRequestSync(context, functionName, functionPath, context.Request.QueryString.ToUriComponent());
var counterLimit = 100;
Expand Down

0 comments on commit 003fde4

Please sign in to comment.