Files
orca/cloud/apps/push/src/push-auth-admission.ts
T
Jinwoo Hong eb2f2d52ae feat(cloud): native push gateway and dedicated infrastructure (1/3) (#19912)
* refactor(cloud): share PostgreSQL schema startup between services

* feat(cloud): add durable native push notification gateway

* infra(push): define dedicated gateway resources and operational checks

* fix(push): bound cross-host admission and simplify gateway configuration

* fix(push): validate deploy configuration and preserve topic-error registrations
2026-09-10 17:59:46 -04:00

22 lines
599 B
TypeScript

// Bound unauthenticated database lookups independently of Cloud Run HTTP concurrency.
export class PushAuthAdmission {
private active = 0
private readonly waiting: (() => void)[] = []
async run<T>(operation: () => Promise<T>): Promise<T | null> {
if (this.active >= 4) {
if (this.waiting.length >= 32) return null
await new Promise<void>((resolve) => this.waiting.push(resolve))
} else {
this.active++
}
try {
return await operation()
} finally {
const next = this.waiting.shift()
if (next) next()
else this.active--
}
}
}