[verified] refactor: establish service and frontend boundaries

This commit is contained in:
chick
2026-07-15 02:43:41 +08:00
parent 0ac6faa6a3
commit e04a16e817
29 changed files with 917 additions and 598 deletions
+14
View File
@@ -0,0 +1,14 @@
export class RequestCoordinator {
#versions = new Map()
async run(channel, ownerId, operation) {
const version = (this.#versions.get(channel) || 0) + 1
this.#versions.set(channel, version)
try {
const value = await operation()
return { accepted: this.#versions.get(channel) === version, ownerId, value }
} catch (error) {
return { accepted: this.#versions.get(channel) === version, ownerId, error }
}
}
invalidate(channel) { this.#versions.set(channel, (this.#versions.get(channel) || 0) + 1) }
}