Skip to content

Commit aa39194

Browse files
committed
• Updated RunQueue.removeEnvironmentQueuesFromMasterQueue() method signature to take runtimeEnvironmentId instead of masterQueue parameter
• Added automatic master queue shard calculation using this.keys.masterQueueKeyForEnvironment(runtimeEnvironmentId, this.shardCount) • Updated RunEngine wrapper method to use new runtimeEnvironmentId parameter • Updated DeleteProjectService to call the method once per environment instead of once per master queue • Simplified API by encapsulating master queue sharding logic within RunQueue class
1 parent 709f2b2 commit aa39194

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

apps/webapp/app/services/deleteProject.server.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,9 @@ export class DeleteProjectService {
4141
}
4242

4343
// Delete all queues from the RunEngine 2 prod master queues
44-
const workerGroups = await this.#prismaClient.workerInstanceGroup.findMany({
45-
select: {
46-
masterQueue: true,
47-
},
48-
});
49-
const engineMasterQueues = workerGroups.map((group) => group.masterQueue);
50-
for (const masterQueue of engineMasterQueues) {
44+
for (const environment of project.environments) {
5145
await engine.removeEnvironmentQueuesFromMasterQueue({
52-
masterQueue,
46+
runtimeEnvironmentId: environment.id,
5347
organizationId: project.organization.id,
5448
projectId: project.id,
5549
});

internal-packages/run-engine/src/engine/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,16 +745,16 @@ export class RunEngine {
745745
}
746746

747747
async removeEnvironmentQueuesFromMasterQueue({
748-
masterQueue,
748+
runtimeEnvironmentId,
749749
organizationId,
750750
projectId,
751751
}: {
752-
masterQueue: string;
752+
runtimeEnvironmentId: string;
753753
organizationId: string;
754754
projectId: string;
755755
}) {
756756
return this.runQueue.removeEnvironmentQueuesFromMasterQueue(
757-
masterQueue,
757+
runtimeEnvironmentId,
758758
organizationId,
759759
projectId
760760
);

internal-packages/run-engine/src/run-queue/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,13 @@ export class RunQueue {
786786
}
787787

788788
public async removeEnvironmentQueuesFromMasterQueue(
789-
masterQueue: string,
789+
runtimeEnvironmentId: string,
790790
organizationId: string,
791791
projectId: string
792792
) {
793+
// Calculate the master queue shard for this environment
794+
const masterQueue = this.keys.masterQueueKeyForEnvironment(runtimeEnvironmentId, this.shardCount);
795+
793796
// Use scanStream to find all matching members
794797
const stream = this.redis.zscanStream(masterQueue, {
795798
match: this.keys.queueKey(organizationId, projectId, "*", "*"),

0 commit comments

Comments
 (0)