Skip to content
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

Circuits lifetime and lifecycle #6353

Closed
danroth27 opened this issue Jan 3, 2019 · 3 comments
Closed

Circuits lifetime and lifecycle #6353

danroth27 opened this issue Jan 3, 2019 · 3 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one

Comments

@danroth27
Copy link
Member

danroth27 commented Jan 3, 2019

Reconnection

  • optimistically restore circuit if not evicted yet
  • rules for eviction
  • UI to tell user they are disconnected and we're trying to reconnect

Disconnection API

  • On .NET side, might be enough that we are disposing the root component
  • On browser side, need to ensure we're exposing something you could hook into with JS
@danroth27 danroth27 added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Jan 3, 2019
@BrennanConroy
Copy link
Member

Blocked is a strong word, you can easily write naive reconnect logic, we even have docs for it. https://docs.microsoft.com/en-us/aspnet/core/signalr/dotnet-client?view=aspnetcore-2.2#handle-lost-connection

@danroth27 danroth27 changed the title Improvements to circuits Circuits lifetime and lifecycle Jan 4, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.0.0-preview3 milestone Jan 16, 2019
@pranavkm
Copy link
Contributor

Meeting notes:

What is a circuit?

  • Ciruit is tied to an individual user (including anonymous users).
  • Has it's own sync context including it's own state such as Renderer. A circuit may have more than one rendered (multi-windows in a browser?)

Features

  • Tomb stoning based on some criteria e.g inactivity
  • Expose events for disconnects
  • Some effort to be made for reconnect. This may be entirely automated or we provide some nice APIs to allow developers to do so.
  • Need to ensure that error handling works with circuits. Ties to (ComponentBase needs proper async error reporting #4964, )

-- Initial pass cut line -- These features don't need to go in the first pass of the feature

  • Reconnect gets the user back to the state prior to disconnect.
  • Some way for the client to say this is the circuit if it disconnects. If the server has the state, we'll use it. If the state has been evicted, we'll need for a way to allow the developer to rehydrate the state and allow the client to connect to it.

UI (load screen \ spinner) for disconnects \ connects

  • We want something like this in the templates by default.

  • We could consider a div on the home page that is hidden by default. Pops up on the client on disconnect.

  • Clean up circuit content

public class Circuit
{
    public Circuit(string id)
    {
        Id = id;
    }

    public string Id { get; }
}

We want to tie the filter to each instance of entry-point (consequently not DI).

builder.UseRazorComponents(x => x.UseCircuitManager<MyCircuitManager>());

public abstract class CircuitHandler
{
    /// <summary>A new circuit was established.</summary>
    public virtual Task OnCircuitOpenedAsync(Circuit circuit, CancellationToken cts) => Task.CompletedTask;

    /// <summary>A connection was established for an existing circuit. Fires once initially and each time during reconnect.</summary>
    public virtual Task OnConnectionUpAsync(Circuit circuit, CancellationToken cts) => Task.CompletedTask;

    /// <summary>A connection was disconnected.</summary>
    public virtual Task OnConnectionDownAsync(Circuit circuit, CancellationToken cts) => Task.CompletedTask;

    /// <summary>A circuit is being discarded. This would be the place to do things like tomb stoning</summary>
    public virtual Task OnCircuitClosedAsync(Circuit circuit, CancellationToken cts) => Task.CompletedTask;
}

// Example of a circuit handler:

public class MyCircuitHandler : CircuitHandler
{
    public override Task OnDisconnectedAsync(Circuit circuit, CancellationToken cts); 
    public override Task OnDisconnectedAsync(Circuit circuit, CancellationToken cts); 
}

Client side events

window.Blazor.onConnectionUp : function() {}    
window.Blazor.onConnectionDown : function() {}

pranavkm added a commit that referenced this issue Feb 4, 2019
Introduce CircuitHandler to handle circuit lifetime events

Partial fix to #6353
@SteveSandersonMS SteveSandersonMS added the area-blazor Includes: Blazor, Razor Components label Feb 6, 2019
@pranavkm pranavkm added Done This issue has been fixed and removed 2 - Working labels Feb 14, 2019
@pranavkm
Copy link
Contributor

Server primitives are done. Client primitives and reconnects are being tracked via #7537

@rynowak rynowak mentioned this issue Mar 4, 2019
56 tasks
@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one
Projects
None yet
Development

No branches or pull requests

5 participants