controller

package
v0.83.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller implements peerliveness.Controller on top of a store.

func NewController

func NewController(store peerliveness.Store) *Controller

NewController returns a Controller that is idle until Start is called.

func (*Controller) Connect

func (c *Controller) Connect(ctx context.Context, accountID, peerID string, session int64) (bool, error)

Connect claims the peer's connection for this instance when session is newer than the stored one. It returns false when a newer session already owns the peer and an error before Start.

func (*Controller) Disconnect

func (c *Controller) Disconnect(ctx context.Context, accountID, peerID string, session int64) (bool, error)

Disconnect releases the peer's connection when it still carries session. It returns false when a newer session owns the peer or no connection exists. When the write fails the error is returned and the release is retried on every heartbeat tick until it applies or the session no longer matches.

func (*Controller) ForgetAccount

func (c *Controller) ForgetAccount(accountID string)

ForgetAccount drops the registry entries and pending releases of the account's peers once the account and its connection records are deleted, so they are not re-registered after a heartbeat lapse.

func (*Controller) ForgetPeer

func (c *Controller) ForgetPeer(peerID string)

ForgetPeer drops the registry entry and any pending release of a peer once it and its connection record are deleted, so it is not re-registered after a heartbeat lapse.

func (*Controller) InstanceID

func (c *Controller) InstanceID() string

InstanceID returns the current instance ID, empty before Start.

func (*Controller) Release

func (c *Controller) Release(ctx context.Context) error

Release stops the heartbeat loop and retires the instance on clean shutdown.

func (*Controller) ReleaseConnection

func (c *Controller) ReleaseConnection(ctx context.Context, accountID, peerID string, session int64) error

ReleaseConnection releases the peer's connection of session on behalf of a login expiry, so no stream of this instance can resurrect it. A newer session is left alone. When the write fails the error is returned and the release is retried on every heartbeat tick until it applies or the session no longer matches. Callers must not hold a store transaction.

func (*Controller) Start

func (c *Controller) Start(ctx context.Context) error

Start registers the instance under a fresh ID, sweeps dead instances once synchronously and then runs the heartbeat loop until ctx is done or Release is called.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL