Skip to content

Commit 6d9f872

Browse files
committed
refactor: remove redundant ConnectionHealthMonitor
The existing ConnectionStateMonitor already provides keep-alive tracking: - Tracks keepAliveState (healthy/unhealthy) - Handles KEEP_ALIVE and KEEP_ALIVE_MISSED events - Maps to ConnectedPendingKeepAlive state when unhealthy Removed duplicate ConnectionHealthMonitor class to reduce code duplication.
1 parent 77e0b95 commit 6d9f872

File tree

4 files changed

+0
-556
lines changed

4 files changed

+0
-556
lines changed

packages/api-graphql/__tests__/utils/ConnectionHealthMonitor.test.ts

Lines changed: 0 additions & 263 deletions
This file was deleted.

packages/api-graphql/src/Providers/AWSWebSocketProvider/index.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ import {
4040
ReconnectEvent,
4141
ReconnectionMonitor,
4242
} from '../../utils/ReconnectionMonitor';
43-
import {
44-
ConnectionHealthMonitor,
45-
type ConnectionHealthState,
46-
} from '../../utils/ConnectionHealthMonitor';
4743
import type { AWSAppSyncRealTimeProviderOptions } from '../AWSAppSyncRealTimeProvider';
4844

4945
import {
@@ -92,7 +88,6 @@ export abstract class AWSWebSocketProvider {
9288
private keepAliveHeartbeatIntervalId?: ReturnType<typeof setInterval>;
9389
private promiseArray: { res(): void; rej(reason?: any): void }[] = [];
9490
private connectionState: ConnectionState | undefined;
95-
private readonly connectionHealthMonitor = new ConnectionHealthMonitor();
9691
private readonly connectionStateMonitor = new ConnectionStateMonitor();
9792
private readonly reconnectionMonitor = new ReconnectionMonitor();
9893
private connectionStateMonitorSubscription: SubscriptionLike;
@@ -111,13 +106,6 @@ export abstract class AWSWebSocketProvider {
111106
/**
112107
* Mark the socket closed and release all active listeners
113108
*/
114-
/**
115-
* Get the connection health state observable
116-
* @returns Observable of connection health state
117-
*/
118-
getConnectionHealthStateObservable(): Observable<ConnectionHealthState> {
119-
return this.connectionHealthMonitor.getHealthStateObservable();
120-
}
121109

122110
close() {
123111
// Mark the socket closed both in status and the connection monitor
@@ -128,8 +116,6 @@ export abstract class AWSWebSocketProvider {
128116
this.connectionStateMonitorSubscription.unsubscribe();
129117
// Complete all reconnect observers
130118
this.reconnectionMonitor.close();
131-
// Close health monitor
132-
this.connectionHealthMonitor.close();
133119

134120
return new Promise<void>((resolve, reject) => {
135121
if (this.awsRealTimeSocket) {
@@ -614,7 +600,6 @@ export abstract class AWSWebSocketProvider {
614600

615601
private maintainKeepAlive() {
616602
this.keepAliveTimestamp = Date.now();
617-
this.connectionHealthMonitor.recordKeepAlive();
618603
}
619604

620605
private keepAliveHeartbeat(connectionTimeoutMs: number) {
@@ -943,7 +928,6 @@ export abstract class AWSWebSocketProvider {
943928

944929
if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
945930
ackOk = true;
946-
this.connectionHealthMonitor.recordConnectionEstablished();
947931
this._registerWebsocketHandlers(connectionTimeoutMs);
948932
resolve('Connected to AWS AppSyncRealTime');
949933

0 commit comments

Comments
 (0)