< Summary

Information
Class: Elsa.Diagnostics.StructuredLogs.RealTime.StructuredLogsHub
Assembly: Elsa.Diagnostics.StructuredLogs
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.StructuredLogs/RealTime/StructuredLogsHub.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 38
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
SubscribeAsync()100%210%
UpdateFilterAsync(...)100%210%
UnsubscribeAsync()100%210%
OnDisconnectedAsync()100%210%
ValidateFilter(...)0%7280%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.StructuredLogs/RealTime/StructuredLogsHub.cs

#LineLine coverage
 1using Elsa.Diagnostics.StructuredLogs.Contracts;
 2using Elsa.Diagnostics.StructuredLogs.Models;
 3using Microsoft.AspNetCore.Authorization;
 4using Microsoft.AspNetCore.SignalR;
 5
 6namespace Elsa.Diagnostics.StructuredLogs.RealTime;
 7
 8[Authorize]
 09public class StructuredLogsHub(StructuredLogSubscriptionManager subscriptionManager) : Hub<IStructuredLogsClient>
 10{
 11    public async Task SubscribeAsync(StructuredLogFilter? filter)
 12    {
 013        await subscriptionManager.SubscribeAsync(Context.ConnectionId, ValidateFilter(filter), Context.ConnectionAborted
 014    }
 15
 016    public Task UpdateFilterAsync(StructuredLogFilter? filter) => subscriptionManager.UpdateFilterAsync(Context.Connecti
 17
 18    public Task UnsubscribeAsync()
 19    {
 020        return subscriptionManager.UnsubscribeAsync(Context.ConnectionId);
 21    }
 22
 23    public override async Task OnDisconnectedAsync(Exception? exception)
 24    {
 025        await UnsubscribeAsync();
 026        await base.OnDisconnectedAsync(exception);
 027    }
 28
 29    private static StructuredLogFilter ValidateFilter(StructuredLogFilter? filter)
 30    {
 031        filter ??= new();
 32
 033        if (filter.From is { } from && filter.To is { } to && from > to)
 034            throw new HubException("The log filter 'from' timestamp must be earlier than or equal to 'to'.");
 35
 036        return filter;
 37    }
 38}