Skip to content

Commit cb7ec48

Browse files
committed
feat(controlplane): run federated composition in worker pool to unblock main event loop
1 parent ac085ab commit cb7ec48

25 files changed

+368
-170
lines changed

controlplane/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"stream-json": "^1.8.0",
9191
"stripe": "^14.19.0",
9292
"tiny-lru": "^11.2.11",
93+
"tinypool": "^2.0.0",
9394
"uid": "^2.0.2",
9495
"uuid": "^10.0.0",
9596
"zod": "^3.22.4",

controlplane/src/core/bufservices/contract/createContract.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export function createContract(
206206
chClient: opts.chClient!,
207207
compositionOptions: newCompositionOptions(req.disableResolvabilityValidation),
208208
federatedGraphs: [{ ...contractGraph, contract }],
209+
composeWorkerPool: opts.composeWorkerPool,
209210
});
210211

211212
compositionErrors.push(...composition.compositionErrors);

controlplane/src/core/bufservices/contract/updateContract.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export function updateContract(
140140
},
141141
labelMatchers: [],
142142
chClient: opts.chClient!,
143+
composeWorkerPool: opts.composeWorkerPool,
143144
compositionOptions: newCompositionOptions(req.disableResolvabilityValidation),
144145
});
145146

@@ -155,6 +156,7 @@ export function updateContract(
155156
},
156157
blobStorage: opts.blobStorage,
157158
chClient: opts.chClient!,
159+
composeWorkerPool: opts.composeWorkerPool,
158160
compositionOptions: newCompositionOptions(req.disableResolvabilityValidation),
159161
federatedGraphs: [
160162
{

controlplane/src/core/bufservices/feature-flag/createFeatureFlag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export function createFeatureFlag(
205205
},
206206
blobStorage: opts.blobStorage,
207207
chClient: opts.chClient!,
208+
composeWorkerPool: opts.composeWorkerPool,
208209
compositionOptions: newCompositionOptions(req.disableResolvabilityValidation),
209210
federatedGraphs,
210211
});

controlplane/src/core/bufservices/feature-flag/deleteFeatureFlag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export function deleteFeatureFlag(
135135
},
136136
blobStorage: opts.blobStorage,
137137
chClient: opts.chClient!,
138+
composeWorkerPool: opts.composeWorkerPool,
138139
compositionOptions: newCompositionOptions(req.disableResolvabilityValidation),
139140
federatedGraphs,
140141
});

controlplane/src/core/bufservices/feature-flag/enableFeatureFlag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export function enableFeatureFlag(
119119
},
120120
blobStorage: opts.blobStorage,
121121
chClient: opts.chClient!,
122+
composeWorkerPool: opts.composeWorkerPool,
122123
compositionOptions: newCompositionOptions(req.disableResolvabilityValidation),
123124
federatedGraphs,
124125
});

controlplane/src/core/bufservices/feature-flag/updateFeatureFlag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export function updateFeatureFlag(
174174
},
175175
blobStorage: opts.blobStorage,
176176
chClient: opts.chClient!,
177+
composeWorkerPool: opts.composeWorkerPool,
177178
compositionOptions: newCompositionOptions(req.disableResolvabilityValidation),
178179
federatedGraphs: allFederatedGraphsToCompose,
179180
});

controlplane/src/core/bufservices/federated-graph/createFederatedGraph.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export function createFederatedGraph(
232232
},
233233
blobStorage: opts.blobStorage,
234234
chClient: opts.chClient!,
235+
composeWorkerPool: opts.composeWorkerPool,
235236
compositionOptions: newCompositionOptions(req.disableResolvabilityValidation),
236237
federatedGraphs: [federatedGraph],
237238
});

controlplane/src/core/bufservices/federated-graph/migrateFromApollo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export function migrateFromApollo(
156156
webhookJWTSecret: opts.admissionWebhookJWTSecret,
157157
},
158158
chClient: opts.chClient!,
159+
composeWorkerPool: opts.composeWorkerPool,
159160
compositionOptions: {
160161
disableResolvabilityValidation: true,
161162
},

controlplane/src/core/bufservices/federated-graph/moveFederatedGraph.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export function moveFederatedGraph(
125125
jwtSecret: opts.admissionWebhookJWTSecret,
126126
},
127127
opts.chClient!,
128+
opts.composeWorkerPool,
128129
);
129130

130131
const allDeploymentErrors: PlainMessage<DeploymentError>[] = [];
@@ -163,6 +164,7 @@ export function moveFederatedGraph(
163164
jwtSecret: opts.admissionWebhookJWTSecret,
164165
},
165166
opts.chClient!,
167+
opts.composeWorkerPool,
166168
);
167169

168170
allCompositionErrors.push(...contractErrors);

0 commit comments

Comments
 (0)