mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
Phase 6 of the relay split: the relay's deploy/operate surface moves under cloud/ with 24 cloud-* workflows gated on ORCA_CLOUD_OPERATIONS_ENABLED, the Cloud SQL rollout lease action, the relay Terraform root (dual-accept identities for both repositories), scripts, docs, CODEOWNERS, and a terraform validate job in Cloud Verify.
25 lines
704 B
TypeScript
25 lines
704 B
TypeScript
export type AssignmentIdentity = {
|
|
userId: string
|
|
relayHostId: string
|
|
}
|
|
|
|
export class AssignmentIdentityQueue {
|
|
private readonly tails = new Map<string, Promise<void>>()
|
|
|
|
async run<T>(identity: AssignmentIdentity, operation: () => Promise<T>): Promise<T> {
|
|
const key = JSON.stringify([identity.userId, identity.relayHostId])
|
|
const previous = this.tails.get(key) ?? Promise.resolve()
|
|
const result = previous.catch(() => undefined).then(operation)
|
|
const tail = result.then(
|
|
() => undefined,
|
|
() => undefined
|
|
)
|
|
this.tails.set(key, tail)
|
|
try {
|
|
return await result
|
|
} finally {
|
|
if (this.tails.get(key) === tail) this.tails.delete(key)
|
|
}
|
|
}
|
|
}
|