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

Allow a Hook to reload an individual client session #402

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on May 10, 2024

  1. Allow a Hook to reload an individual client session

    In a clustered environment, client connections are distributed among
    multiple Server instances on different machines. After a client
    disconnects, leaving behind a persistent session state, its next
    login is likely to be on a different node. Because of this, in such a
    setup an individual Server instance should only keep Client instances
    corresponding to online client connections, and it should be able to
    reload an individual client's state (presumably from persistent
    storage) when that client connects.
    
    This commit adds support for such an environment by adding a new hook
    `StoredClientByID`. An implementation finds and returns any
    persistent client data for a given session ID. In practice the only
    necessary information turned out to be the saved subscriptions and
    in-flight ack messages. The hook also returns the prior 'Remote'
    property since the server logs that.
    
    The Server method `inheritClientSession` is extended to call this hook
    if there is no matching in-memory Client session. If the hook returns
    session data, it installs it into the Client object in the same way
    as the existing code.
    
    At the end of the Server method `attachClient`, after disconnection,
    the existence of a `StoredClientByID` hook is checked; if present,
    the method expires the Client instance so it won't hang around in
    memory and so the next connection will go to the hook to reload
    state.
    snej committed May 10, 2024
    Configuration menu
    Copy the full SHA
    32b4386 View commit details
    Browse the repository at this point in the history