feat: Automatically recover from frozen live streams (#2569)
- Closes: #2099
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { RecoverableHealthInterface, UnlistenCallback } from '../../health';
|
||||
import type { RecoverableHealthInterface } from '../../health';
|
||||
import type { UnsubscribeCallback } from '../../types';
|
||||
import type { HASSWebSocketSubscriptionStatus } from './subscription-manager';
|
||||
|
||||
// One keyed subscription that is currently failing, with the most recent
|
||||
@@ -76,7 +77,7 @@ export class SubscriptionHealthMonitor<K, R> implements SubscriptionHealthInterf
|
||||
return [...failing.values()];
|
||||
}
|
||||
|
||||
public addListener(listener: () => void): UnlistenCallback {
|
||||
public addListener(listener: () => void): UnsubscribeCallback {
|
||||
this._listeners.add(listener);
|
||||
return () => {
|
||||
this._listeners.delete(listener);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import type { Connection } from 'home-assistant-js-websocket';
|
||||
|
||||
import type { UnsubscribeCallback } from '../../types';
|
||||
import {
|
||||
KeyedSubscriptionManager,
|
||||
type GetKeyCallback,
|
||||
} from '../../utils/concurrency/keyed-subscription-manager';
|
||||
import { RetryTimer } from '../../utils/retry-timer';
|
||||
import { isHassReady } from '../is-hass-ready';
|
||||
import type { HASSSource, HASSUnlistenCallback } from '../source';
|
||||
import type { HASSSource } from '../source';
|
||||
import type { HomeAssistant } from '../types';
|
||||
import type { HASSWebSocketLiveness, HASSWebSocketOpenCallback } from './types';
|
||||
|
||||
@@ -117,7 +118,7 @@ export class HASSConnectionSubscriptionManager<K, R> {
|
||||
// subscribe/unsubscribe.
|
||||
private _requests = new Map<R, RequestRegistration<K, R>>();
|
||||
|
||||
private _unlistenCallback: HASSUnlistenCallback | null = null;
|
||||
private _unlistenCallback: UnsubscribeCallback | null = null;
|
||||
|
||||
constructor(getKeyCallback: GetKeyCallback<R, K>, source: HASSSource) {
|
||||
this._getKeyCallback = getKeyCallback;
|
||||
|
||||
+2
-3
@@ -1,3 +1,4 @@
|
||||
import type { UnsubscribeCallback } from '../types';
|
||||
import type { HomeAssistant } from './types';
|
||||
|
||||
/**
|
||||
@@ -8,9 +9,7 @@ import type { HomeAssistant } from './types';
|
||||
*/
|
||||
export type HASSListener = (hass: HomeAssistant, oldHass: HomeAssistant | null) => void;
|
||||
|
||||
export type HASSUnlistenCallback = () => void;
|
||||
|
||||
export interface HASSSource {
|
||||
getHASS(): HomeAssistant | null;
|
||||
addListener(listener: HASSListener): HASSUnlistenCallback;
|
||||
addListener(listener: HASSListener): UnsubscribeCallback;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user