Skip to content

Commit

Permalink
chore: apply various updates
Browse files Browse the repository at this point in the history
  • Loading branch information
engineering87 committed Dec 10, 2024
1 parent a97db5a commit 924af08
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/WART-Client/WartTestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static async Task ConnectAsync(string wartHubUrl)
}
catch (Exception e)
{
Console.WriteLine(e);
Console.WriteLine(e.Message);
}

await Task.CompletedTask;
Expand Down
2 changes: 1 addition & 1 deletion src/WART-Client/WartTestClientJwt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static async Task ConnectAsync(string wartHubUrl, string key)
}
catch (Exception e)
{
Console.WriteLine(e);
Console.WriteLine(e.Message);
}

await Task.CompletedTask;
Expand Down
15 changes: 1 addition & 14 deletions src/WART-Core/Controllers/WartBaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,8 @@ public override void OnActionExecuted(ActionExecutedContext context)

var wartEvent = new WartEvent(request, response, httpMethod, httpPath, remoteAddress);

// Fire-and-forget
//Task.Run(() => SendToHub(wartEvent, [.. context.Filters]))
// .ContinueWith(task =>
// {
// if (task.IsFaulted)
// {
// _logger?.LogError(task.Exception, "Error sending WartEvent.");
// }
// });

_eventQueue = context.HttpContext?.RequestServices.GetService<WartEventQueueService>();
if (_eventQueue != null)
{
_eventQueue.Enqueue(new WartEventWithFilters(wartEvent, [.. context.Filters]));
}
_eventQueue?.Enqueue(new WartEventWithFilters(wartEvent, [.. context.Filters]));
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/WART-Core/Services/WartEventWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// Check if there are any connected clients.
if (!WartHubBase.HasConnectedClients)
{
_logger.LogInformation("No clients connected. Pausing event processing.");
{
await Task.Delay(500, stoppingToken);
continue;
}
Expand Down Expand Up @@ -96,7 +95,7 @@ private async Task SendToHub(WartEvent wartEvent, List<IFilterMetadata> filters)
var groups = GetTargetGroups(filters);

// If specific groups are defined, send the event to each group in parallel.
if (groups.Any())
if (groups.Count != 0)
{
var tasks = groups.Select(group => SendEventToGroup(wartEvent, group));
await Task.WhenAll(tasks);
Expand Down

0 comments on commit 924af08

Please sign in to comment.