-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not delete the AgentUserRelation #8246
Conversation
* @param options.concurrency - Maximum number of parallel executions (default: 8) | ||
* @returns Promise resolving to array of results in the same order as input items. | ||
*/ | ||
export async function concurrentExecutor<T, V>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with:
async function main() {
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
console.log("Starting execution...");
const results = await concurrentExecutor(
items,
async (item, idx) => {
console.log(`Starting task ${idx} (value: ${item})`);
// Random delay.
const delay = Math.floor(Math.random() * 2000) + 1000;
await new Promise((resolve) => setTimeout(resolve, delay));
console.log(`Completed task ${idx} (value: ${item}) after ${delay}ms`);
return item * 2;
},
{ concurrency: 3 }
);
console.log("All tasks completed!");
console.log("Results:", results);
}
main().catch(console.error);
Yields:
Starting execution...
Starting task 0 (value: 1)
Starting task 1 (value: 2)
Starting task 2 (value: 3)
Completed task 1 (value: 2) after 1213ms
Starting task 3 (value: 4)
Completed task 2 (value: 3) after 1592ms
Starting task 4 (value: 5)
Completed task 3 (value: 4) after 1571ms
Starting task 5 (value: 6)
Completed task 0 (value: 1) after 2803ms
Starting task 6 (value: 7)
Completed task 4 (value: 5) after 1259ms
Starting task 7 (value: 8)
Completed task 7 (value: 8) after 2066ms
Starting task 8 (value: 9)
Completed task 6 (value: 7) after 2322ms
Starting task 9 (value: 10)
Completed task 5 (value: 6) after 2557ms
Completed task 9 (value: 10) after 1817ms
Completed task 8 (value: 9) after 2269ms
All tasks completed!
Results: [
2, 4, 6, 8, 10,
12, 14, 16, 18, 20
]
WHyyyyyyyy oh whyyy ? :) (more seriously, if we already had one way, why add another way ?) |
p-queue isn't a dependency of |
Description
This PR updates the existing remove draft agent configuration scripts to avoid deleting the
UserAgentRelation
.I took the opportunity to add some concurrency by bringing
concurrentExecutor
intypes
. We have an existing implementation in connectors that usesp-queue
🤮. This one is pure TS.Will update connectors to use this new implementation.
Risk
Deploy Plan