Skip to content

Commit b2a3cb1

Browse files
committed
Dashboard line record
1 parent 357be26 commit b2a3cb1

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

src/Aspire.Dashboard/Components/Controls/LogViewer.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
4040
private readonly List<LogEntry> _logEntries = new();
4141
private int? _baseLineNumber;
4242

43-
internal async Task SetLogSourceAsync(IAsyncEnumerable<IReadOnlyList<(int LineNumber, string Content, bool IsErrorMessage)>> batches, bool convertTimestampsFromUtc)
43+
internal async Task SetLogSourceAsync(IAsyncEnumerable<IReadOnlyList<ResourceLogLine>> batches, bool convertTimestampsFromUtc)
4444
{
4545
_convertTimestampsFromUtc = convertTimestampsFromUtc;
4646

src/Aspire.Dashboard/Model/DashboardClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ async IAsyncEnumerable<IReadOnlyList<ResourceViewModelChange>> StreamUpdatesAsyn
426426
}
427427
}
428428

429-
async IAsyncEnumerable<IReadOnlyList<(int LineNumber, string Content, bool IsErrorMessage)>>? IDashboardClient.SubscribeConsoleLogs(string resourceName, [EnumeratorCancellation] CancellationToken cancellationToken)
429+
async IAsyncEnumerable<IReadOnlyList<ResourceLogLine>>? IDashboardClient.SubscribeConsoleLogs(string resourceName, [EnumeratorCancellation] CancellationToken cancellationToken)
430430
{
431431
EnsureInitialized();
432432

@@ -438,7 +438,7 @@ async IAsyncEnumerable<IReadOnlyList<ResourceViewModelChange>> StreamUpdatesAsyn
438438

439439
// Write incoming logs to a channel, and then read from that channel to yield the logs.
440440
// We do this to batch logs together and enforce a minimum read interval.
441-
var channel = Channel.CreateUnbounded<IReadOnlyList<(int LineNumber, string Content, bool IsErrorMessage)>>(
441+
var channel = Channel.CreateUnbounded<IReadOnlyList<ResourceLogLine>>(
442442
new UnboundedChannelOptions { AllowSynchronousContinuations = false, SingleReader = true, SingleWriter = true });
443443

444444
var readTask = Task.Run(async () =>
@@ -447,11 +447,11 @@ async IAsyncEnumerable<IReadOnlyList<ResourceViewModelChange>> StreamUpdatesAsyn
447447
{
448448
await foreach (var response in call.ResponseStream.ReadAllAsync(cancellationToken: combinedTokens.Token))
449449
{
450-
var logLines = new (int LineNumber, string Content, bool IsErrorMessage)[response.LogLines.Count];
450+
var logLines = new ResourceLogLine[response.LogLines.Count];
451451

452452
for (var i = 0; i < logLines.Length; i++)
453453
{
454-
logLines[i] = (response.LogLines[i].LineNumber, response.LogLines[i].Text, response.LogLines[i].IsStdErr);
454+
logLines[i] = new ResourceLogLine(response.LogLines[i].LineNumber, response.LogLines[i].Text, response.LogLines[i].IsStdErr);
455455
}
456456

457457
// Channel is unbound so TryWrite always succeeds.

src/Aspire.Dashboard/Model/IDashboardClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public interface IDashboardClient : IAsyncDisposable
4949
/// </remarks>
5050
/// <para>It is important that callers trigger <paramref name="cancellationToken"/>
5151
/// so that resources owned by the sequence and its consumers can be freed.</para>
52-
IAsyncEnumerable<IReadOnlyList<(int LineNumber, string Content, bool IsErrorMessage)>>? SubscribeConsoleLogs(string resourceName, CancellationToken cancellationToken);
52+
IAsyncEnumerable<IReadOnlyList<ResourceLogLine>>? SubscribeConsoleLogs(string resourceName, CancellationToken cancellationToken);
5353

5454
Task<ResourceCommandResponseViewModel> ExecuteResourceCommandAsync(string resourceName, string resourceType, CommandViewModel command, CancellationToken cancellationToken);
5555
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Aspire.Dashboard.Model;
5+
6+
public readonly record struct ResourceLogLine(int LineNumber, string Content, bool IsErrorMessage)
7+
{
8+
}

tests/Aspire.Dashboard.Components.Tests/Controls/ApplicationNameTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private sealed class MockDashboardClient : IDashboardClient
5151
public string ApplicationName => "<marquee>An HTML title!</marquee>";
5252
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
5353
public Task<ResourceCommandResponseViewModel> ExecuteResourceCommandAsync(string resourceName, string resourceType, CommandViewModel command, CancellationToken cancellationToken) => throw new NotImplementedException();
54-
public IAsyncEnumerable<IReadOnlyList<(int LineNumber, string Content, bool IsErrorMessage)>>? SubscribeConsoleLogs(string resourceName, CancellationToken cancellationToken) => throw new NotImplementedException();
54+
public IAsyncEnumerable<IReadOnlyList<ResourceLogLine>>? SubscribeConsoleLogs(string resourceName, CancellationToken cancellationToken) => throw new NotImplementedException();
5555
public Task<ResourceViewModelSubscription> SubscribeResourcesAsync(CancellationToken cancellationToken) => throw new NotImplementedException();
5656
}
5757
}

tests/Aspire.Dashboard.Tests/ResourceOutgoingPeerResolverTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private sealed class MockDashboardClient(Task<ResourceViewModelSubscription> sub
181181
public string ApplicationName => "ApplicationName";
182182
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
183183
public Task<ResourceCommandResponseViewModel> ExecuteResourceCommandAsync(string resourceName, string resourceType, CommandViewModel command, CancellationToken cancellationToken) => throw new NotImplementedException();
184-
public IAsyncEnumerable<IReadOnlyList<(int LineNumber, string Content, bool IsErrorMessage)>>? SubscribeConsoleLogs(string resourceName, CancellationToken cancellationToken) => throw new NotImplementedException();
184+
public IAsyncEnumerable<IReadOnlyList<ResourceLogLine>>? SubscribeConsoleLogs(string resourceName, CancellationToken cancellationToken) => throw new NotImplementedException();
185185
public Task<ResourceViewModelSubscription> SubscribeResourcesAsync(CancellationToken cancellationToken) => subscribeResult;
186186
}
187187
}

0 commit comments

Comments
 (0)