-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce CircuitHandler to handle circuit lifetime events #6971
Conversation
src/Components/Server/src/Builder/RazorComponentsApplicationBuilderExtensions.cs
Show resolved
Hide resolved
src/Components/Server/src/Circuits/DefaultCircuitFactoryOptions.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems super on the right track.
d11b9c1
to
303c592
Compare
7d853aa
to
16228c6
Compare
src/Components/test/testassets/ComponentsApp.App/ComponentsApp.App.csproj
Outdated
Show resolved
Hide resolved
🆙 📅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
103360c
to
3923d89
Compare
Weird, I don't see why I was triggered as a code owner. |
src/Components/Server/src/Circuits/DefaultCircuitFactoryOptions.cs
Outdated
Show resolved
Hide resolved
3923d89
to
b6c8581
Compare
85e398c
to
0eb3cfc
Compare
🆙 📅 |
/// Invoked when a new circuit was established. | ||
/// </summary> | ||
/// <param name="circuit">The <see cref="Circuit"/>.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to specify what this particular CancellationToken
represents. What operation does it represent the cancellation of? Also in the other methods in this class.
|
||
Renderer.UnhandledException += Renderer_UnhandledException; | ||
SynchronizationContext.UnhandledException += SynchronizationContext_UnhandledException; | ||
} | ||
|
||
public string CircuitId { get; } = Guid.NewGuid().ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any security concerns here if this is guessable? Might a third party be able to "reconnect" to someone else's circuit and obtain their state? If so we might need to generate this value using RNGCryptoServiceProvider
or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracking via #7243
{ | ||
for (var i = 0; i < _circuitHandlers.Length; i++) | ||
{ | ||
await _circuitHandlers[i].OnConnectionDownAsync(Circuit, default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to keep it simple for now, but later we might want to pass some flag to OnConnectionDownAsync
to indicate that we're "disposing" deliberately, rather than encountering an unexpected connection loss. People may want to log unexpected connection loss, or perhaps skip the "serialize state" job if it's a deliberate shutdown.
@@ -13,9 +13,9 @@ | |||
namespace Microsoft.AspNetCore.Components.Server | |||
{ | |||
/// <summary> | |||
/// A SignalR hub that accepts connections to a Server-Side Blazor app. | |||
/// A SignalR hub that accepts connections to a ASP.NET Core Components WebApp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: WebApp
is an odd term. Maybe web application
would be more consistent with usage elsewhere :)
Also we usually say "an ASP.NET Core..." rather than "a ASP.NET Core...". Minor details though, I know!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks superb to me.
/// </summary> | ||
public class Circuit | ||
public sealed class Circuit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this class? It only has a single ID and a _circuitHost that is not accessible outside this class. Can't the Id be moved to the CircuitHost class and this class be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect Circuit
to be the user facing type. CircuitHost
is an implementation detail.
{ | ||
Scope = scope ?? throw new ArgumentNullException(nameof(scope)); | ||
_scope = scope ?? throw new ArgumentNullException(nameof(scope)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at some point we should do cleanup of our DI usage across circuits and Components. We shouldn't be passing DI abstractions around unless the specific class is a composition root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The circuit host is the owner of the scope which is why it's here.
0eb3cfc
to
62d10bc
Compare
Partial fix to #6353