@@ -7,40 +7,6 @@ export type ComputeMigrationFlags = {
77 computeMigrationPaidPercentage ?: number ;
88} ;
99
10- export type ComputeBackingMap = Record < string , string > ;
11-
12- /**
13- * Parse COMPUTE_BACKING_MAP (container-region masterQueue -> compute-backing
14- * masterQueue). Never throws: bad JSON or non-string values yield {} so a
15- * misconfigured env disables migration rather than breaking triggers.
16- */
17- export function parseComputeBackingMap ( raw : string ) : ComputeBackingMap {
18- try {
19- const parsed = JSON . parse ( raw ) ;
20- if ( typeof parsed !== "object" || parsed === null ) return { } ;
21- const out : ComputeBackingMap = { } ;
22- for ( const [ k , v ] of Object . entries ( parsed ) ) {
23- if ( typeof v === "string" ) out [ k ] = v ;
24- }
25- return out ;
26- } catch {
27- return { } ;
28- }
29- }
30-
31- /**
32- * Inverse of the backing map: given a worker queue, return the user-facing geo
33- * region. If the queue is a compute backing (a *value* in the map), return the
34- * region it backs; otherwise return the queue unchanged. Used to hide the
35- * backing on customer surfaces and to re-derive the region on replay.
36- */
37- export function regionForBacking ( queue : string , backingMap : ComputeBackingMap ) : string {
38- for ( const [ region , backing ] of Object . entries ( backingMap ) ) {
39- if ( backing === queue ) return region ;
40- }
41- return queue ;
42- }
43-
4410type MigrationDecisionInput = {
4511 planType : string | undefined ;
4612 orgId : string ;
@@ -81,7 +47,7 @@ export function isOrgMigrated({
8147type ResolveInput = MigrationDecisionInput & {
8248 baseWorkerQueue : string | undefined ;
8349 envType : string ;
84- backingMap : ComputeBackingMap ;
50+ backing : string | undefined ; // the compute backing for this queue's region, or undefined
8551} ;
8652
8753/**
@@ -93,11 +59,11 @@ type ResolveInput = MigrationDecisionInput & {
9359export function resolveComputeMigration ( {
9460 baseWorkerQueue,
9561 envType,
96- backingMap ,
62+ backing ,
9763 ...decision
9864} : ResolveInput ) : string | undefined {
9965 if ( baseWorkerQueue === undefined ) return baseWorkerQueue ;
10066 if ( envType === "DEVELOPMENT" ) return baseWorkerQueue ;
10167 if ( ! isOrgMigrated ( decision ) ) return baseWorkerQueue ;
102- return backingMap [ baseWorkerQueue ] ?? baseWorkerQueue ;
68+ return backing ?? baseWorkerQueue ;
10369}
0 commit comments