feat(backend): make FeedSourceProvider async

Make feedSourceForUser and FeedSourceProviderFn return promises.
Use Promise.allSettled to tolerate partial provider failures.
Guard concurrent getOrCreate calls with in-flight promise dedup.
Return 503 from HTTP handlers when session creation fails.

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2026-03-15 19:11:03 +00:00
parent 8eedd1f4fd
commit ce5dc7fbd3
9 changed files with 216 additions and 76 deletions

View File

@@ -1,9 +1,9 @@
import type { FeedSource } from "@aelis/core"
export interface FeedSourceProvider {
feedSourceForUser(userId: string): FeedSource
feedSourceForUser(userId: string): Promise<FeedSource>
}
export type FeedSourceProviderFn = (userId: string) => FeedSource
export type FeedSourceProviderFn = (userId: string) => Promise<FeedSource>
export type FeedSourceProviderInput = FeedSourceProvider | FeedSourceProviderFn