@stage-labs/metro 0.1.0-beta.324 → 0.1.0-beta.325
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/package.json
CHANGED
|
@@ -43,7 +43,7 @@ function helpersBody(setup: ModelSetup): Record<string, unknown> | null {
|
|
|
43
43
|
const helpers = helperSetup(setup);
|
|
44
44
|
if (helpers === null) return null;
|
|
45
45
|
const primary = primaryRoute(helpers);
|
|
46
|
-
return { route: primary?.connection.id ?? '', model: primary?.model ?? '', fallbacks: helpers.fallbacks, chain: chainStatus(helpers) };
|
|
46
|
+
return { route: primary?.connection.id ?? '', model: primary?.model ?? '', fallbacks: helpers.fallbacks, chain: chainStatus(helpers, Date.now(), setupNotReady) };
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export function settingsBody(deps: ModelApiDeps): Record<string, unknown> {
|
|
@@ -59,7 +59,7 @@ export function settingsBody(deps: ModelApiDeps): Record<string, unknown> {
|
|
|
59
59
|
reason,
|
|
60
60
|
connections: setup.connections.map(publicConnection),
|
|
61
61
|
fallbacks: setup.fallbacks,
|
|
62
|
-
chain: chainStatus(setup),
|
|
62
|
+
chain: chainStatus(setup, Date.now(), setupNotReady),
|
|
63
63
|
helpers: helpersBody(setup),
|
|
64
64
|
effort: { ...EFFORT_DEFAULTS, ...setup.effort },
|
|
65
65
|
};
|
|
@@ -131,20 +131,22 @@ function primaryOf(setup: ModelSetup): Route | null {
|
|
|
131
131
|
return { connection: primary.connection, model };
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
type Readiness = (route: Route) => string | null;
|
|
135
|
+
|
|
136
|
+
function rowOf(route: Route, now: number, ready: Readiness): Omit<ChainRow, 'active'> {
|
|
137
|
+
const reason = ready(route);
|
|
136
138
|
const used = windowsFor(route, now).reduce<number | null>((most, w) => Math.max(most ?? 0, w.used ?? 0), null);
|
|
137
139
|
return { connection: route.connection.id, model: route.model, used, hold: reason === null ? holdOf(route, now) : { reason, until: null } };
|
|
138
140
|
}
|
|
139
141
|
|
|
140
|
-
export function chainStatus(setup: ModelSetup, now = Date.now()): ChainRow[] {
|
|
142
|
+
export function chainStatus(setup: ModelSetup, now = Date.now(), ready: Readiness = notReady): ChainRow[] {
|
|
141
143
|
const primary = primaryOf(setup);
|
|
142
144
|
if (primary === null) return [];
|
|
143
145
|
const listed = setup.fallbacks.flatMap((f) => {
|
|
144
146
|
const conn = connectionOf(setup, f.connection);
|
|
145
147
|
return conn === null ? [] : [{ connection: conn, model: f.model }];
|
|
146
148
|
});
|
|
147
|
-
const rows = unique([primary, ...listed]).map((route) => rowOf(route, now));
|
|
149
|
+
const rows = unique([primary, ...listed]).map((route) => rowOf(route, now, ready));
|
|
148
150
|
const active = Math.max(0, rows.findIndex((row) => row.hold === null));
|
|
149
151
|
return rows.map((row, at) => ({ ...row, active: at === active }));
|
|
150
152
|
}
|
package/runtime/runtime.json
CHANGED