mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 13:03:46 +00:00
foundry: parallelize app snapshot org reads
This commit is contained in:
parent
6e216a9f86
commit
252fbdc93b
2 changed files with 18 additions and 13 deletions
|
|
@ -29,6 +29,7 @@ WorkspaceActor
|
|||
- Branch rename is a real git operation, not just metadata.
|
||||
- `SandboxInstanceActor` stays separate from `TaskActor`; tasks/sessions reference it by identity.
|
||||
- Sync actors are polling workers only. They feed parent actors and should not become the source of truth.
|
||||
- When a backend request path must aggregate multiple independent actor calls or reads, prefer bounded parallelism over sequential fan-out when correctness permits. Do not serialize independent work by default.
|
||||
|
||||
## Maintenance
|
||||
|
||||
|
|
|
|||
|
|
@ -230,19 +230,23 @@ async function buildAppSnapshot(c: any, sessionId: string): Promise<FoundryAppSn
|
|||
const session = await requireAppSessionRow(c, sessionId);
|
||||
const eligibleOrganizationIds = parseEligibleOrganizationIds(session.eligibleOrganizationIdsJson);
|
||||
|
||||
const organizations: FoundryOrganization[] = [];
|
||||
for (const organizationId of eligibleOrganizationIds) {
|
||||
try {
|
||||
const workspace = await getOrCreateWorkspace(c, organizationId);
|
||||
const organizationState = await getOrganizationState(workspace);
|
||||
organizations.push(organizationState.snapshot);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
if (!message.includes("Actor not found")) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
const organizations = (
|
||||
await Promise.all(
|
||||
eligibleOrganizationIds.map(async (organizationId) => {
|
||||
try {
|
||||
const workspace = await getOrCreateWorkspace(c, organizationId);
|
||||
const organizationState = await getOrganizationState(workspace);
|
||||
return organizationState.snapshot;
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
if (!message.includes("Actor not found")) {
|
||||
throw error;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}),
|
||||
)
|
||||
).filter((organization): organization is FoundryOrganization => organization !== null);
|
||||
|
||||
const currentUser: FoundryUser | null = session.currentUserId
|
||||
? {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue