Documentation
¶
Index ¶
- type Controller
- func (c *Controller) Connect(ctx context.Context, accountID, peerID string, session int64) (bool, error)
- func (c *Controller) Disconnect(ctx context.Context, accountID, peerID string, session int64) (bool, error)
- func (c *Controller) ForgetAccount(accountID string)
- func (c *Controller) ForgetPeer(peerID string)
- func (c *Controller) InstanceID() string
- func (c *Controller) Release(ctx context.Context) error
- func (c *Controller) ReleaseConnection(ctx context.Context, accountID, peerID string, session int64) error
- func (c *Controller) Start(ctx context.Context) error
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.