@babylonjs-toolkit/server 0.0.0-stage → 9.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CUSTOM.md +1690 -0
- package/DEPLOY.md +2012 -0
- package/README.md +1081 -2
- package/lib/AbuseLimits.d.ts +64 -0
- package/lib/AbuseLimits.js +121 -0
- package/lib/Authentication.d.ts +86 -0
- package/lib/Authentication.js +272 -0
- package/lib/BootSessionOwner.d.ts +86 -0
- package/lib/BootSessionOwner.js +116 -0
- package/lib/ColyseusLoggerAdapter.d.ts +32 -0
- package/lib/ColyseusLoggerAdapter.js +73 -0
- package/lib/DedicatedSceneRegistry.d.ts +52 -0
- package/lib/DedicatedSceneRegistry.js +74 -0
- package/lib/DedicatedSession.d.ts +152 -0
- package/lib/DedicatedSession.js +173 -0
- package/lib/DualTransport.d.ts +112 -0
- package/lib/DualTransport.js +197 -0
- package/lib/GameServer.d.ts +64 -0
- package/lib/GameServer.js +647 -0
- package/lib/GameServerConfig.d.ts +387 -0
- package/lib/GameServerConfig.js +1059 -0
- package/lib/GameServerLobbyRoom.d.ts +33 -0
- package/lib/GameServerLobbyRoom.js +56 -0
- package/lib/GameServerLogger.d.ts +111 -0
- package/lib/GameServerLogger.js +190 -0
- package/lib/GameServerMetrics.d.ts +158 -0
- package/lib/GameServerMetrics.js +276 -0
- package/lib/GameServerState.d.ts +164 -0
- package/lib/GameServerState.js +26 -0
- package/lib/HeadlessRuntime.d.ts +316 -0
- package/lib/HeadlessRuntime.js +380 -0
- package/lib/JoinGate.d.ts +34 -0
- package/lib/JoinGate.js +221 -0
- package/lib/NetworkAddresses.d.ts +33 -0
- package/lib/NetworkAddresses.js +90 -0
- package/lib/PlayerTokens.d.ts +17 -0
- package/lib/PlayerTokens.js +24 -0
- package/lib/RoomServerTransport.d.ts +73 -0
- package/lib/RoomServerTransport.js +90 -0
- package/lib/ServerEndpoints.d.ts +133 -0
- package/lib/ServerEndpoints.js +247 -0
- package/lib/ServerInit.d.ts +28 -0
- package/lib/ServerInit.js +113 -0
- package/lib/SessionRoom.d.ts +391 -0
- package/lib/SessionRoom.js +930 -0
- package/lib/TlsCertificates.d.ts +35 -0
- package/lib/TlsCertificates.js +130 -0
- package/lib/admin/AccountRoutes.d.ts +8 -0
- package/lib/admin/AccountRoutes.js +502 -0
- package/lib/admin/AdminAccounts.d.ts +329 -0
- package/lib/admin/AdminAccounts.js +607 -0
- package/lib/admin/AdminApiRouter.d.ts +202 -0
- package/lib/admin/AdminApiRouter.js +465 -0
- package/lib/admin/AdminApiTypes.d.ts +1782 -0
- package/lib/admin/AdminApiTypes.js +4 -0
- package/lib/admin/AdminAudit.d.ts +113 -0
- package/lib/admin/AdminAudit.js +266 -0
- package/lib/admin/AdminCli.d.ts +7 -0
- package/lib/admin/AdminCli.js +351 -0
- package/lib/admin/AdminClock.d.ts +51 -0
- package/lib/admin/AdminClock.js +10 -0
- package/lib/admin/AdminConsole.d.ts +39 -0
- package/lib/admin/AdminConsole.js +325 -0
- package/lib/admin/AdminConstants.d.ts +147 -0
- package/lib/admin/AdminConstants.js +167 -0
- package/lib/admin/AdminCrypto.d.ts +19 -0
- package/lib/admin/AdminCrypto.js +29 -0
- package/lib/admin/AdminExtensionsHost.d.ts +176 -0
- package/lib/admin/AdminExtensionsHost.js +307 -0
- package/lib/admin/AdminPasswords.d.ts +33 -0
- package/lib/admin/AdminPasswords.js +92 -0
- package/lib/admin/AdminPermissions.d.ts +28 -0
- package/lib/admin/AdminPermissions.js +74 -0
- package/lib/admin/AdminRecords.d.ts +196 -0
- package/lib/admin/AdminRecords.js +3 -0
- package/lib/admin/AdminRequestBodies.d.ts +47 -0
- package/lib/admin/AdminRequestBodies.js +84 -0
- package/lib/admin/AdminRequestGate.d.ts +38 -0
- package/lib/admin/AdminRequestGate.js +59 -0
- package/lib/admin/AdminResponses.d.ts +103 -0
- package/lib/admin/AdminResponses.js +164 -0
- package/lib/admin/AdminServices.d.ts +99 -0
- package/lib/admin/AdminServices.js +4 -0
- package/lib/admin/AdminStaticFiles.d.ts +29 -0
- package/lib/admin/AdminStaticFiles.js +97 -0
- package/lib/admin/AdminStore.d.ts +152 -0
- package/lib/admin/AdminStore.js +46 -0
- package/lib/admin/AlertChannels.d.ts +43 -0
- package/lib/admin/AlertChannels.js +120 -0
- package/lib/admin/AlertEngine.d.ts +231 -0
- package/lib/admin/AlertEngine.js +681 -0
- package/lib/admin/AlertRoutes.d.ts +8 -0
- package/lib/admin/AlertRoutes.js +180 -0
- package/lib/admin/ApiKeyRoutes.d.ts +8 -0
- package/lib/admin/ApiKeyRoutes.js +53 -0
- package/lib/admin/ApiKeys.d.ts +63 -0
- package/lib/admin/ApiKeys.js +167 -0
- package/lib/admin/AuditRoutes.d.ts +8 -0
- package/lib/admin/AuditRoutes.js +106 -0
- package/lib/admin/AuthToolRoutes.d.ts +13 -0
- package/lib/admin/AuthToolRoutes.js +164 -0
- package/lib/admin/BanList.d.ts +87 -0
- package/lib/admin/BanList.js +152 -0
- package/lib/admin/CborDecoder.d.ts +18 -0
- package/lib/admin/CborDecoder.js +201 -0
- package/lib/admin/ColyseusCloudClient.d.ts +313 -0
- package/lib/admin/ColyseusCloudClient.js +272 -0
- package/lib/admin/ColyseusCloudRoutes.d.ts +8 -0
- package/lib/admin/ColyseusCloudRoutes.js +91 -0
- package/lib/admin/ColyseusCloudService.d.ts +180 -0
- package/lib/admin/ColyseusCloudService.js +476 -0
- package/lib/admin/ColyseusCloudSettings.d.ts +16 -0
- package/lib/admin/ColyseusCloudSettings.js +29 -0
- package/lib/admin/ColyseusCloudViews.d.ts +105 -0
- package/lib/admin/ColyseusCloudViews.js +371 -0
- package/lib/admin/CommonPasswords.d.ts +6 -0
- package/lib/admin/CommonPasswords.js +19 -0
- package/lib/admin/ConfigOverrides.d.ts +174 -0
- package/lib/admin/ConfigOverrides.js +406 -0
- package/lib/admin/ConfigRoutes.d.ts +8 -0
- package/lib/admin/ConfigRoutes.js +91 -0
- package/lib/admin/ConsoleSessions.d.ts +112 -0
- package/lib/admin/ConsoleSessions.js +201 -0
- package/lib/admin/DedicatedRoutes.d.ts +21 -0
- package/lib/admin/DedicatedRoutes.js +254 -0
- package/lib/admin/ExtensionRoutes.d.ts +8 -0
- package/lib/admin/ExtensionRoutes.js +145 -0
- package/lib/admin/FileAdminStore.d.ts +157 -0
- package/lib/admin/FileAdminStore.js +349 -0
- package/lib/admin/FleetDirectory.d.ts +323 -0
- package/lib/admin/FleetDirectory.js +489 -0
- package/lib/admin/FleetLeader.d.ts +43 -0
- package/lib/admin/FleetLeader.js +89 -0
- package/lib/admin/FleetRoutes.d.ts +55 -0
- package/lib/admin/FleetRoutes.js +465 -0
- package/lib/admin/HealthWarnings.d.ts +10 -0
- package/lib/admin/HealthWarnings.js +95 -0
- package/lib/admin/LeaderboardRoutes.d.ts +8 -0
- package/lib/admin/LeaderboardRoutes.js +569 -0
- package/lib/admin/LogBuffer.d.ts +60 -0
- package/lib/admin/LogBuffer.js +92 -0
- package/lib/admin/LogRedaction.d.ts +15 -0
- package/lib/admin/LogRedaction.js +72 -0
- package/lib/admin/LogRoutes.d.ts +45 -0
- package/lib/admin/LogRoutes.js +307 -0
- package/lib/admin/MaintenanceMode.d.ts +41 -0
- package/lib/admin/MaintenanceMode.js +74 -0
- package/lib/admin/MaintenanceWindows.d.ts +91 -0
- package/lib/admin/MaintenanceWindows.js +207 -0
- package/lib/admin/MetricsRoutes.d.ts +8 -0
- package/lib/admin/MetricsRoutes.js +209 -0
- package/lib/admin/MetricsSampler.d.ts +124 -0
- package/lib/admin/MetricsSampler.js +211 -0
- package/lib/admin/OneTimeCodes.d.ts +60 -0
- package/lib/admin/OneTimeCodes.js +162 -0
- package/lib/admin/OpenIdConnect.d.ts +146 -0
- package/lib/admin/OpenIdConnect.js +335 -0
- package/lib/admin/Passkeys.d.ts +130 -0
- package/lib/admin/Passkeys.js +432 -0
- package/lib/admin/PlayerRoutes.d.ts +20 -0
- package/lib/admin/PlayerRoutes.js +676 -0
- package/lib/admin/RedisAdminStore.d.ts +114 -0
- package/lib/admin/RedisAdminStore.js +258 -0
- package/lib/admin/RolloutCoordinator.d.ts +99 -0
- package/lib/admin/RolloutCoordinator.js +321 -0
- package/lib/admin/ServerEvents.d.ts +57 -0
- package/lib/admin/ServerEvents.js +89 -0
- package/lib/admin/SessionRoutes.d.ts +113 -0
- package/lib/admin/SessionRoutes.js +386 -0
- package/lib/admin/UserRoutes.d.ts +8 -0
- package/lib/admin/UserRoutes.js +214 -0
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +221 -0
- package/lib/console/assets/index-CI5N7c-T.js +21 -0
- package/lib/console/assets/index-DPitvzLp.css +1 -0
- package/lib/console/favicon.svg +1 -0
- package/lib/console/index.html +16 -0
- package/lib/discord/DiscordOAuth.d.ts +57 -0
- package/lib/discord/DiscordOAuth.js +127 -0
- package/lib/discord/DiscordSessions.d.ts +79 -0
- package/lib/discord/DiscordSessions.js +135 -0
- package/lib/discord/DiscordSignInConstants.d.ts +54 -0
- package/lib/discord/DiscordSignInConstants.js +55 -0
- package/lib/discord/DiscordSignInRoutes.d.ts +51 -0
- package/lib/discord/DiscordSignInRoutes.js +359 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +18 -0
- package/lib/leaderboards/FileLeaderboardRankStore.d.ts +293 -0
- package/lib/leaderboards/FileLeaderboardRankStore.js +808 -0
- package/lib/leaderboards/LeaderboardConstants.d.ts +63 -0
- package/lib/leaderboards/LeaderboardConstants.js +70 -0
- package/lib/leaderboards/LeaderboardError.d.ts +15 -0
- package/lib/leaderboards/LeaderboardError.js +20 -0
- package/lib/leaderboards/LeaderboardIdentity.d.ts +44 -0
- package/lib/leaderboards/LeaderboardIdentity.js +72 -0
- package/lib/leaderboards/LeaderboardPublicApi.d.ts +17 -0
- package/lib/leaderboards/LeaderboardPublicApi.js +389 -0
- package/lib/leaderboards/LeaderboardRankStore.d.ts +296 -0
- package/lib/leaderboards/LeaderboardRankStore.js +18 -0
- package/lib/leaderboards/LeaderboardRules.d.ts +122 -0
- package/lib/leaderboards/LeaderboardRules.js +472 -0
- package/lib/leaderboards/LeaderboardScheduler.d.ts +43 -0
- package/lib/leaderboards/LeaderboardScheduler.js +103 -0
- package/lib/leaderboards/LeaderboardService.d.ts +669 -0
- package/lib/leaderboards/LeaderboardService.js +1667 -0
- package/lib/leaderboards/LeaderboardTransfer.d.ts +35 -0
- package/lib/leaderboards/LeaderboardTransfer.js +580 -0
- package/lib/leaderboards/RedisLeaderboardRankStore.d.ts +282 -0
- package/lib/leaderboards/RedisLeaderboardRankStore.js +691 -0
- package/package.json +64 -4
- package/templates/init/Caddyfile +6 -0
- package/templates/init/DEPLOY.md +233 -0
- package/templates/init/Dockerfile +12 -0
- package/templates/init/app.json +21 -0
- package/templates/init/aws/README.md +118 -0
- package/templates/init/aws/ecs-fargate-alb.yml +207 -0
- package/templates/init/aws/ecs-fargate-nlb-quic.yml +210 -0
- package/templates/init/babylon-game-server.config.mjs +158 -0
- package/templates/init/colyseus-cloud/README.md +133 -0
- package/templates/init/colyseus-cloud/babylon-game-server.config.mjs +36 -0
- package/templates/init/colyseus-cloud/ecosystem.config.cjs +35 -0
- package/templates/init/colyseus-cloud/gitignore +6 -0
- package/templates/init/colyseus-cloud/package.json +15 -0
- package/templates/init/digitalocean-app.yaml +30 -0
- package/templates/init/docker-compose.full.yml +45 -0
- package/templates/init/docker-compose.websocket.yml +41 -0
- package/templates/init/fly.toml +56 -0
- package/templates/init/heroku.yml +11 -0
- package/templates/init/kubernetes/deployment.yaml +71 -0
- package/templates/init/kubernetes/redis.yaml +73 -0
- package/templates/init/kubernetes/service.yaml +24 -0
- package/templates/init/monitoring/grafana-dashboard.json +539 -0
- package/templates/init/monitoring/prometheus-alerts.yml +51 -0
- package/templates/init/monitoring/prometheus-scrape.yml +17 -0
- package/templates/init/railway.json +13 -0
- package/templates/init/render.yaml +19 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import type { TlsMaterial } from "../TlsCertificates.js";
|
|
2
|
+
import type { AdminLogLevel, AdminNoticePayload, DedicatedStartedBy, DrainStartedView, InstanceHeartbeat, InstancesDrainRequest, InstanceView, LobbyKickRequest, LobbyKickView, LogEntryView, MaintenanceState, NoticeSentView, PlayerSummaryView, SceneCheckView, SessionSummaryView } from "./AdminApiTypes.js";
|
|
3
|
+
import type { AdminCoreServices } from "./AdminServices.js";
|
|
4
|
+
import type { AdminCollection } from "./AdminStore.js";
|
|
5
|
+
import type { LogFilter } from "./LogBuffer.js";
|
|
6
|
+
/** Arguments and results of every fleet command (R15). Commands with nothing to pass or return use null. */
|
|
7
|
+
export interface FleetCommandContract {
|
|
8
|
+
describeSessions: {
|
|
9
|
+
arguments: null;
|
|
10
|
+
result: SessionSummaryView[];
|
|
11
|
+
};
|
|
12
|
+
searchPlayers: {
|
|
13
|
+
arguments: {
|
|
14
|
+
search: string;
|
|
15
|
+
includeAddresses: boolean;
|
|
16
|
+
};
|
|
17
|
+
result: PlayerSummaryView[];
|
|
18
|
+
};
|
|
19
|
+
setMaintenance: {
|
|
20
|
+
arguments: MaintenanceState;
|
|
21
|
+
result: null;
|
|
22
|
+
};
|
|
23
|
+
clearMaintenance: {
|
|
24
|
+
arguments: null;
|
|
25
|
+
result: null;
|
|
26
|
+
};
|
|
27
|
+
drain: {
|
|
28
|
+
arguments: InstancesDrainRequest;
|
|
29
|
+
result: DrainStartedView;
|
|
30
|
+
};
|
|
31
|
+
sendNotice: {
|
|
32
|
+
arguments: {
|
|
33
|
+
roomId: string | null;
|
|
34
|
+
playerId: number;
|
|
35
|
+
notice: AdminNoticePayload;
|
|
36
|
+
};
|
|
37
|
+
result: NoticeSentView;
|
|
38
|
+
};
|
|
39
|
+
disconnectBanned: {
|
|
40
|
+
arguments: {
|
|
41
|
+
banIds: string[];
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
44
|
+
result: {
|
|
45
|
+
disconnected: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
kickFromLobby: {
|
|
49
|
+
arguments: LobbyKickRequest;
|
|
50
|
+
result: LobbyKickView;
|
|
51
|
+
};
|
|
52
|
+
readLogs: {
|
|
53
|
+
arguments: {
|
|
54
|
+
filter: LogFilter;
|
|
55
|
+
afterSequence: number;
|
|
56
|
+
limit: number;
|
|
57
|
+
};
|
|
58
|
+
result: LogEntryView[];
|
|
59
|
+
};
|
|
60
|
+
setLogLevel: {
|
|
61
|
+
arguments: {
|
|
62
|
+
level: AdminLogLevel;
|
|
63
|
+
revertAfterMinutes: number;
|
|
64
|
+
};
|
|
65
|
+
result: null;
|
|
66
|
+
};
|
|
67
|
+
checkDedicatedScene: {
|
|
68
|
+
arguments: {
|
|
69
|
+
sceneName: string;
|
|
70
|
+
};
|
|
71
|
+
result: SceneCheckView;
|
|
72
|
+
};
|
|
73
|
+
startDedicated: {
|
|
74
|
+
arguments: {
|
|
75
|
+
sceneName: string;
|
|
76
|
+
sessionName: string;
|
|
77
|
+
startedBy: DedicatedStartedBy;
|
|
78
|
+
};
|
|
79
|
+
result: {
|
|
80
|
+
roomId: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
reloadAuthKeys: {
|
|
84
|
+
arguments: null;
|
|
85
|
+
result: null;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** Names of the commands one instance can ask another to run (D16). */
|
|
89
|
+
export type FleetCommandName = keyof FleetCommandContract;
|
|
90
|
+
/** The arguments of a command. */
|
|
91
|
+
export type FleetCommandArguments<Name extends FleetCommandName> = FleetCommandContract[Name]["arguments"];
|
|
92
|
+
/** The result of a command. */
|
|
93
|
+
export type FleetCommandResult<Name extends FleetCommandName> = FleetCommandContract[Name]["result"];
|
|
94
|
+
/** Runs one command on this instance. */
|
|
95
|
+
export type FleetCommandHandler<Name extends FleetCommandName> = (commandArguments: FleetCommandArguments<Name>) => Promise<FleetCommandResult<Name>>;
|
|
96
|
+
/** A command request on the bus. */
|
|
97
|
+
export interface FleetCommand {
|
|
98
|
+
commandId: string;
|
|
99
|
+
name: FleetCommandName;
|
|
100
|
+
arguments: unknown;
|
|
101
|
+
replyTopic: string;
|
|
102
|
+
fromProcessId: string;
|
|
103
|
+
}
|
|
104
|
+
/** A command reply on the bus. */
|
|
105
|
+
export interface FleetCommandReply {
|
|
106
|
+
commandId: string;
|
|
107
|
+
processId: string;
|
|
108
|
+
ok: boolean;
|
|
109
|
+
result: unknown;
|
|
110
|
+
error: string | null;
|
|
111
|
+
/** The HTTP status of an AdminRequestError the handler threw, so the caller answers with it; else null. */
|
|
112
|
+
status: number | null;
|
|
113
|
+
}
|
|
114
|
+
/** A fan-out result: failed instances are reported, not thrown. */
|
|
115
|
+
export interface FleetFanOutResult<Result> {
|
|
116
|
+
results: {
|
|
117
|
+
processId: string;
|
|
118
|
+
result: Result;
|
|
119
|
+
}[];
|
|
120
|
+
failures: {
|
|
121
|
+
processId: string;
|
|
122
|
+
error: string;
|
|
123
|
+
}[];
|
|
124
|
+
}
|
|
125
|
+
/** One instance's entry in the heartbeat hash: its newest heartbeat and the one its counter rates are measured from. */
|
|
126
|
+
export interface StoredHeartbeat {
|
|
127
|
+
/** The newest heartbeat. */
|
|
128
|
+
heartbeat: InstanceHeartbeat;
|
|
129
|
+
/** The latest earlier heartbeat with different counters, or null before there is one. */
|
|
130
|
+
previous: InstanceHeartbeat | null;
|
|
131
|
+
}
|
|
132
|
+
/** One instance as the overview reads it: its view and the heartbeat its rates are measured from. */
|
|
133
|
+
export interface FleetInstanceRecord {
|
|
134
|
+
/** The instance row. */
|
|
135
|
+
view: InstanceView;
|
|
136
|
+
/** The earlier heartbeat of the rates, or null. */
|
|
137
|
+
previous: InstanceHeartbeat | null;
|
|
138
|
+
}
|
|
139
|
+
/** Calls back on an announced change of a store collection. */
|
|
140
|
+
export type FleetChangeListener = (collection: AdminCollection) => void;
|
|
141
|
+
/** Heartbeats, the command bus and change announcements of this instance. */
|
|
142
|
+
export declare class FleetDirectory {
|
|
143
|
+
/** The shared core services. */
|
|
144
|
+
private readonly services;
|
|
145
|
+
/** Command handlers by name (each name once). */
|
|
146
|
+
private readonly handlers;
|
|
147
|
+
/** Listeners of change announcements. */
|
|
148
|
+
private readonly changeListeners;
|
|
149
|
+
/** The event-loop delay histogram, while started. */
|
|
150
|
+
private eventLoopMonitor;
|
|
151
|
+
/** The heartbeat timer, while started. */
|
|
152
|
+
private heartbeatTimer;
|
|
153
|
+
/** True while a heartbeat is being written, so a slow store never stacks them. */
|
|
154
|
+
private isWritingHeartbeat;
|
|
155
|
+
/** The newest heartbeat this instance wrote, or null. */
|
|
156
|
+
private lastHeartbeat;
|
|
157
|
+
/** The heartbeat the counter rates are measured from, or null. */
|
|
158
|
+
private rateBaseHeartbeat;
|
|
159
|
+
/** The counter snapshot of the newest heartbeat (the metrics cache hands the same object until it renews). */
|
|
160
|
+
private lastSnapshot;
|
|
161
|
+
/** CPU time used up to the last heartbeat. */
|
|
162
|
+
private lastCpuUsage;
|
|
163
|
+
/** High-resolution time of the last CPU sample, in nanoseconds. */
|
|
164
|
+
private lastCpuSampleAt;
|
|
165
|
+
/** Real time of the last "heartbeat failed" warning, in milliseconds. */
|
|
166
|
+
private lastHeartbeatWarningAt;
|
|
167
|
+
/** The subscribed command listener, while started. */
|
|
168
|
+
private readonly commandListener;
|
|
169
|
+
/** The subscribed change listener, while started. */
|
|
170
|
+
private readonly changeListener;
|
|
171
|
+
/**
|
|
172
|
+
* Prepares the directory; nothing is published until start().
|
|
173
|
+
* @param services The shared core services.
|
|
174
|
+
*/
|
|
175
|
+
constructor(services: AdminCoreServices);
|
|
176
|
+
/** This instance's process id (matchMaker.processId, R5). */
|
|
177
|
+
get localProcessId(): string;
|
|
178
|
+
/** True when Redis connects the fleet; false for a single instance. */
|
|
179
|
+
get isScaledOut(): boolean;
|
|
180
|
+
/** Starts heartbeats, command handling and change announcements; the first heartbeat is written at once. */
|
|
181
|
+
start(): Promise<void>;
|
|
182
|
+
/** Stops heartbeats and command handling and removes this instance's heartbeat (R4). */
|
|
183
|
+
stop(): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Every known instance with its status, newest heartbeat first.
|
|
186
|
+
* @returns The instance rows.
|
|
187
|
+
*/
|
|
188
|
+
listInstances(): Promise<InstanceView[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Every known instance with the heartbeat its rates are measured from, newest heartbeat first. Instances silent
|
|
191
|
+
* for FLEET_LOST_AFTER_MS are "lost"; those silent for FLEET_FORGET_AFTER_MS are removed from the hash.
|
|
192
|
+
* @returns The records.
|
|
193
|
+
*/
|
|
194
|
+
listInstanceRecords(): Promise<FleetInstanceRecord[]>;
|
|
195
|
+
/**
|
|
196
|
+
* Drops (and forgets) each lost instance whose public address a newer live instance now serves: that instance was
|
|
197
|
+
* restarted in its place, so it is no longer lost (T14: restarting a lost instance resolves its alert).
|
|
198
|
+
* @param records The instances, newest heartbeat first.
|
|
199
|
+
* @returns The records without the restarted instances.
|
|
200
|
+
*/
|
|
201
|
+
private withoutRestartedInstances;
|
|
202
|
+
/**
|
|
203
|
+
* Runs a command on one instance: in-process when it is this one, else over the bus.
|
|
204
|
+
* @param processId The instance.
|
|
205
|
+
* @param name The command.
|
|
206
|
+
* @param commandArguments Its arguments.
|
|
207
|
+
* @returns The command's result.
|
|
208
|
+
* @throws AdminRequestError 404 for an unknown or lost instance, 504 when no reply came in time, or the status the
|
|
209
|
+
* handler refused with.
|
|
210
|
+
*/
|
|
211
|
+
runOn<Name extends FleetCommandName>(processId: string, name: Name, commandArguments: FleetCommandArguments<Name>): Promise<FleetCommandResult<Name>>;
|
|
212
|
+
/**
|
|
213
|
+
* Runs a command on every live instance (this one always included).
|
|
214
|
+
* @param name The command.
|
|
215
|
+
* @param commandArguments Its arguments.
|
|
216
|
+
* @returns Each instance's result, and the instances that failed.
|
|
217
|
+
*/
|
|
218
|
+
runOnAll<Name extends FleetCommandName>(name: Name, commandArguments: FleetCommandArguments<Name>): Promise<FleetFanOutResult<FleetCommandResult<Name>>>;
|
|
219
|
+
/**
|
|
220
|
+
* Registers this instance's handler of a command.
|
|
221
|
+
* @param name The command.
|
|
222
|
+
* @param handler Runs it; its arguments and result are copies (structured clones).
|
|
223
|
+
* @throws Error when the command already has a handler.
|
|
224
|
+
*/
|
|
225
|
+
handle<Name extends FleetCommandName>(name: Name, handler: FleetCommandHandler<Name>): void;
|
|
226
|
+
/**
|
|
227
|
+
* Publishes that a store collection changed, so every instance (this one included) reloads it.
|
|
228
|
+
* @param collection The collection.
|
|
229
|
+
*/
|
|
230
|
+
announceChange(collection: AdminCollection): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* Calls back on every announced change (any instance, this one included).
|
|
233
|
+
* @param listener The listener.
|
|
234
|
+
*/
|
|
235
|
+
onChange(listener: FleetChangeListener): void;
|
|
236
|
+
/**
|
|
237
|
+
* The presence every instance shares (Redis when scaled out). Colyseus sets it when the server listens.
|
|
238
|
+
* @returns The presence.
|
|
239
|
+
*/
|
|
240
|
+
private presence;
|
|
241
|
+
/**
|
|
242
|
+
* Runs a registered handler on this instance with copies of the arguments and the result, since local presence
|
|
243
|
+
* hands objects over by reference.
|
|
244
|
+
* @param name The command.
|
|
245
|
+
* @param commandArguments Its arguments.
|
|
246
|
+
* @returns A copy of the result.
|
|
247
|
+
* @throws AdminRequestError 501 when no handler is registered.
|
|
248
|
+
*/
|
|
249
|
+
private runLocally;
|
|
250
|
+
/**
|
|
251
|
+
* Sends a command to another instance and waits for its reply on a per-command topic.
|
|
252
|
+
* @param processId The instance.
|
|
253
|
+
* @param name The command.
|
|
254
|
+
* @param commandArguments Its arguments.
|
|
255
|
+
* @returns The result.
|
|
256
|
+
* @throws AdminRequestError on a failed reply or after FLEET_COMMAND_TIMEOUT_MS.
|
|
257
|
+
*/
|
|
258
|
+
private sendCommand;
|
|
259
|
+
/**
|
|
260
|
+
* Subscribes to a command's reply topic, publishes the command and resolves with the reply.
|
|
261
|
+
* @param command The command.
|
|
262
|
+
* @param processId The instance it goes to.
|
|
263
|
+
* @returns The reply.
|
|
264
|
+
* @throws AdminRequestError 504 after FLEET_COMMAND_TIMEOUT_MS.
|
|
265
|
+
*/
|
|
266
|
+
private awaitReply;
|
|
267
|
+
/**
|
|
268
|
+
* Runs a command another instance sent and publishes the reply.
|
|
269
|
+
* @param command The command.
|
|
270
|
+
*/
|
|
271
|
+
private receiveCommand;
|
|
272
|
+
/**
|
|
273
|
+
* Runs a received command and turns its outcome into a reply.
|
|
274
|
+
* @param command The command.
|
|
275
|
+
* @returns The reply.
|
|
276
|
+
*/
|
|
277
|
+
private answerCommand;
|
|
278
|
+
/**
|
|
279
|
+
* Calls every change listener; a listener that throws is logged and the others still run.
|
|
280
|
+
* @param collection The changed collection.
|
|
281
|
+
*/
|
|
282
|
+
private notifyChange;
|
|
283
|
+
/**
|
|
284
|
+
* Removes a long-lost instance from the heartbeat hash.
|
|
285
|
+
* @param processId The instance.
|
|
286
|
+
*/
|
|
287
|
+
private forgetInstance;
|
|
288
|
+
/** Builds and writes this instance's heartbeat; a failure is logged at warn once per minute (DR §9). */
|
|
289
|
+
private writeHeartbeat;
|
|
290
|
+
/**
|
|
291
|
+
* Builds the next heartbeat entry, moving the rate base forward whenever the counters were renewed.
|
|
292
|
+
* @returns The entry to store.
|
|
293
|
+
*/
|
|
294
|
+
private nextStoredHeartbeat;
|
|
295
|
+
/**
|
|
296
|
+
* This instance's heartbeat now (DR §6.5).
|
|
297
|
+
* @param snapshot The metrics counters, or null when metrics are off (the counters are then 0).
|
|
298
|
+
* @returns The heartbeat.
|
|
299
|
+
*/
|
|
300
|
+
private buildHeartbeat;
|
|
301
|
+
/**
|
|
302
|
+
* CPU use since the last heartbeat, as a percent of one core (user plus system time over elapsed time).
|
|
303
|
+
* @returns The percent.
|
|
304
|
+
*/
|
|
305
|
+
private sampleCpuPercent;
|
|
306
|
+
/**
|
|
307
|
+
* The mean event-loop delay since the last heartbeat; the histogram restarts afterwards.
|
|
308
|
+
* @returns The delay, in milliseconds (0 before any sample).
|
|
309
|
+
*/
|
|
310
|
+
private sampleEventLoopLag;
|
|
311
|
+
/**
|
|
312
|
+
* Logs a failed heartbeat at warn, at most once per HEARTBEAT_WARNING_INTERVAL_MS.
|
|
313
|
+
* @param error What failed.
|
|
314
|
+
*/
|
|
315
|
+
private warnHeartbeatFailure;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Days until the served certificate expires (DR §8), rounded down.
|
|
319
|
+
* @param material The TLS material served now, or null without TLS.
|
|
320
|
+
* @param nowMilliseconds The current time.
|
|
321
|
+
* @returns The days left (negative once expired), or null without TLS or for an unreadable certificate.
|
|
322
|
+
*/
|
|
323
|
+
export declare function certificateDaysLeft(material: TlsMaterial | null, nowMilliseconds: number): number | null;
|