Commit a38eb4f
committed
refactor(webapp): per-org basins for paid orgs only
Free orgs share the global stream basin (the existing legacy fallback
path); paid orgs get a dedicated per-org basin with retention tied to
their tier. Cleaner story, much smaller S2 footprint, and basin
existence becomes a real tier benefit rather than a default for
everyone.
A single `v3.reconcileStreamBasinForOrg` worker job handles every
plan transition idempotently:
free → paid: provision a new basin, stamp `Organization.streamBasinName`.
paid → paid: reconfigure retention (tier-change). S2 retention only
takes effect on new streams, but that's fine — old
streams age out on their original retention.
paid → free: null `Organization.streamBasinName`. Future runs/sessions
for this org route through the shared global basin via
the existing read-precedence fallback. The per-org basin
lingers; existing streams there respect their original
retention until they age out.
free → free: no-op.
Replaces the previous `provisionStreamBasinForOrg` /
`reconfigureStreamBasinForOrg` job pair so callers don't have to
choose the right job for the transition. `setPlan` enqueues
`reconcile` from all three plan-changed branches; the admin backfill
route enqueues `reconcile` for every non-deleted org (idempotent — the
worker decides per-org what to do).
Org create no longer provisions synchronously — new orgs start free
and use the shared basin until their first paid upgrade.
Verified locally: backfill correctly deprovisioned 4 free orgs (column
nulled, basins left intact) and kept the 1 hobby-tier org's basin.
A fresh chat for a free org streams into the shared basin under the
legacy prefix `org/{orgId}/env/.../sessions/{chatId}/{io}` with no
new streams in the old per-org basin.1 parent 054d1af commit a38eb4f
6 files changed
Lines changed: 184 additions & 153 deletions
File tree
- apps/webapp/app
- models
- routes
- services
- realtime
- v3
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
| |||
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
106 | 92 | | |
107 | 93 | | |
108 | 94 | | |
| |||
Lines changed: 25 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
30 | 26 | | |
31 | 27 | | |
32 | 28 | | |
| |||
59 | 55 | | |
60 | 56 | | |
61 | 57 | | |
62 | | - | |
63 | | - | |
64 | 58 | | |
65 | 59 | | |
66 | 60 | | |
| |||
76 | 70 | | |
77 | 71 | | |
78 | 72 | | |
79 | | - | |
80 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
81 | 77 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 78 | + | |
86 | 79 | | |
87 | 80 | | |
88 | 81 | | |
89 | 82 | | |
90 | 83 | | |
91 | | - | |
92 | | - | |
93 | | - | |
| 84 | + | |
| 85 | + | |
94 | 86 | | |
95 | 87 | | |
96 | 88 | | |
| |||
99 | 91 | | |
100 | 92 | | |
101 | 93 | | |
102 | | - | |
| 94 | + | |
103 | 95 | | |
104 | 96 | | |
105 | 97 | | |
106 | 98 | | |
107 | 99 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 100 | | |
112 | 101 | | |
113 | 102 | | |
114 | 103 | | |
115 | | - | |
| 104 | + | |
116 | 105 | | |
117 | | - | |
| 106 | + | |
118 | 107 | | |
119 | 108 | | |
120 | 109 | | |
| |||
130 | 119 | | |
131 | 120 | | |
132 | 121 | | |
133 | | - | |
| 122 | + | |
134 | 123 | | |
135 | 124 | | |
136 | 125 | | |
137 | | - | |
| 126 | + | |
138 | 127 | | |
139 | 128 | | |
140 | 129 | | |
| |||
149 | 138 | | |
150 | 139 | | |
151 | 140 | | |
152 | | - | |
| 141 | + | |
153 | 142 | | |
154 | 143 | | |
155 | | - | |
156 | 144 | | |
157 | 145 | | |
158 | 146 | | |
159 | 147 | | |
160 | 148 | | |
161 | | - | |
162 | | - | |
163 | | - | |
| 149 | + | |
| 150 | + | |
164 | 151 | | |
165 | 152 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
444 | 453 | | |
445 | | - | |
| 454 | + | |
446 | 455 | | |
447 | 456 | | |
448 | 457 | | |
449 | | - | |
| 458 | + | |
450 | 459 | | |
451 | 460 | | |
452 | | - | |
453 | | - | |
454 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
455 | 464 | | |
456 | 465 | | |
457 | | - | |
| 466 | + | |
458 | 467 | | |
459 | 468 | | |
460 | 469 | | |
| |||
0 commit comments