Server reale e veste Docker (M5): composizione, collegamento, vista remota, salute, immagine e modello Unraid
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
35 files changed
+6124
-10
No files matched your search
@@ -0,0 +1,89 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Channels;
|
||||
using Febe.Web.Connection;
|
||||
|
||||
namespace Febe.Tests.Server.Support;
|
||||
|
||||
/// <summary>A remote view without browser: the test writes what goes to the page and reads what comes back.</summary>
|
||||
internal sealed class FakeRemoteViewHost : IRemoteViewHost
|
||||
{
|
||||
private readonly Lock _gate = new();
|
||||
|
||||
public List<FakeRemoteViewConnection> Opened { get; } = [];
|
||||
|
||||
public bool Unavailable { get; set; }
|
||||
|
||||
public Task<IRemoteViewConnection> OpenAsync(CancellationToken ct)
|
||||
{
|
||||
if (Unavailable)
|
||||
{
|
||||
throw new RemoteViewUnavailableException("Il browser di prova non c'è.");
|
||||
}
|
||||
|
||||
var connection = new FakeRemoteViewConnection();
|
||||
lock (_gate)
|
||||
{
|
||||
if (Opened.LastOrDefault() is { Disposed: false } previous)
|
||||
{
|
||||
previous.End(RemoteViewEnd.Replaced);
|
||||
}
|
||||
|
||||
Opened.Add(connection);
|
||||
}
|
||||
|
||||
return Task.FromResult<IRemoteViewConnection>(connection);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class FakeRemoteViewConnection : IRemoteViewConnection
|
||||
{
|
||||
private readonly Channel<RemoteViewOutput> _output = Channel.CreateUnbounded<RemoteViewOutput>();
|
||||
|
||||
public ConcurrentQueue<object> Inputs { get; } = new();
|
||||
|
||||
public bool Disposed { get; private set; }
|
||||
|
||||
public RemoteViewEnd? Ended { get; private set; }
|
||||
|
||||
public void Write(RemoteViewOutput output) => _output.Writer.TryWrite(output);
|
||||
|
||||
public void End(RemoteViewEnd reason)
|
||||
{
|
||||
Ended = reason;
|
||||
_output.Writer.TryComplete();
|
||||
}
|
||||
|
||||
public async IAsyncEnumerable<RemoteViewOutput> ReadAsync([EnumeratorCancellation] CancellationToken ct)
|
||||
{
|
||||
await foreach (var output in _output.Reader.ReadAllAsync(ct))
|
||||
{
|
||||
yield return output;
|
||||
}
|
||||
}
|
||||
|
||||
public Task MouseAsync(RemoteViewMouse input, CancellationToken ct)
|
||||
{
|
||||
Inputs.Enqueue(input);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task KeyAsync(RemoteViewKey input, CancellationToken ct)
|
||||
{
|
||||
Inputs.Enqueue(input);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task NavigateAsync(RemoteViewNavigation action, CancellationToken ct)
|
||||
{
|
||||
Inputs.Enqueue(action);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
Disposed = true;
|
||||
_output.Writer.TryComplete();
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user