@fluidframework/container-runtime 2.74.0-368706 → 2.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/container-runtime.test-files.tar +0 -0
- package/dist/channelCollection.d.ts.map +1 -1
- package/dist/channelCollection.js +20 -2
- package/dist/channelCollection.js.map +1 -1
- package/dist/dataStoreContexts.d.ts +56 -9
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/dataStoreContexts.js +56 -9
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/runtimeLayerCompatState.d.ts +2 -2
- package/dist/runtimeLayerCompatState.js +1 -1
- package/dist/runtimeLayerCompatState.js.map +1 -1
- package/eslint.config.mts +31 -0
- package/lib/channelCollection.d.ts.map +1 -1
- package/lib/channelCollection.js +20 -2
- package/lib/channelCollection.js.map +1 -1
- package/lib/dataStoreContexts.d.ts +56 -9
- package/lib/dataStoreContexts.d.ts.map +1 -1
- package/lib/dataStoreContexts.js +56 -9
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/runtimeLayerCompatState.d.ts +2 -2
- package/lib/runtimeLayerCompatState.js +1 -1
- package/lib/runtimeLayerCompatState.js.map +1 -1
- package/package.json +21 -20
- package/src/channelCollection.ts +26 -2
- package/src/dataStoreContexts.ts +56 -9
- package/src/packageVersion.ts +1 -1
- package/src/runtimeLayerCompatState.ts +1 -1
package/src/dataStoreContexts.ts
CHANGED
|
@@ -13,27 +13,41 @@ import {
|
|
|
13
13
|
import type { FluidDataStoreContext, LocalFluidDataStoreContext } from "./dataStoreContext.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
+
* Manages the collection of data store contexts, tracking their bound/unbound state.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* A context is "unbound" when it's created locally but not yet made visible (reachable from root).
|
|
20
|
+
* A context is "bound" once it's made locally visible, regardless of the Container's attach state.
|
|
21
|
+
* In attached containers, binding a context immediately sends an attach op and transitions it to Attaching state.
|
|
22
|
+
*
|
|
16
23
|
* @internal
|
|
17
24
|
*/
|
|
18
25
|
export class DataStoreContexts
|
|
19
26
|
implements Iterable<[string, FluidDataStoreContext]>, IDisposable
|
|
20
27
|
{
|
|
28
|
+
/**
|
|
29
|
+
* Set of IDs for contexts that are unbound (not yet made locally visible).
|
|
30
|
+
* These contexts exist locally but aren't known to other clients (even in an attached container).
|
|
31
|
+
*/
|
|
21
32
|
private readonly notBoundContexts = new Set<string>();
|
|
22
33
|
|
|
23
34
|
/**
|
|
24
|
-
*
|
|
35
|
+
* Map of all data store contexts (both bound and unbound).
|
|
25
36
|
*/
|
|
26
37
|
private readonly _contexts = new Map<string, FluidDataStoreContext>();
|
|
27
38
|
|
|
28
39
|
/**
|
|
29
40
|
* List of pending context waiting either to be bound or to arrive from another client.
|
|
30
41
|
* This covers the case where a local context has been created but not yet bound,
|
|
31
|
-
* or the case where a client knows a store will exist and is waiting on its creation,
|
|
42
|
+
* or the case where a client knows a store will exist (e.g. by alias) and is waiting on its creation,
|
|
32
43
|
* so that a caller may await the deferred's promise until such a time as the context is fully ready.
|
|
33
44
|
* This is a superset of _contexts, since contexts remain here once the Deferred resolves.
|
|
34
45
|
*/
|
|
35
46
|
private readonly deferredContexts = new Map<string, Deferred<FluidDataStoreContext>>();
|
|
36
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Lazy disposal logic that disposes all contexts when called.
|
|
50
|
+
*/
|
|
37
51
|
// eslint-disable-next-line unicorn/consistent-function-scoping -- Property is defined once; no need to extract inner lambda
|
|
38
52
|
private readonly disposeOnce = new Lazy<void>(() => {
|
|
39
53
|
// close/stop all store contexts
|
|
@@ -73,22 +87,39 @@ export class DataStoreContexts
|
|
|
73
87
|
}
|
|
74
88
|
public readonly dispose = (): void => this.disposeOnce.value;
|
|
75
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Returns the count of unbound contexts (i.e. local-only on this client)
|
|
92
|
+
*/
|
|
76
93
|
public notBoundLength(): number {
|
|
77
94
|
return this.notBoundContexts.size;
|
|
78
95
|
}
|
|
79
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Returns true if the given ID corresponds to an unbound context. (i.e. local-only on this client)
|
|
99
|
+
*/
|
|
80
100
|
public isNotBound(id: string): boolean {
|
|
81
101
|
return this.notBoundContexts.has(id);
|
|
82
102
|
}
|
|
83
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Returns true if a context with the given ID exists (bound or unbound).
|
|
106
|
+
*/
|
|
84
107
|
public has(id: string): boolean {
|
|
85
108
|
return this._contexts.has(id);
|
|
86
109
|
}
|
|
87
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Returns the context with the given ID, or undefined if not found.
|
|
113
|
+
* This returns both bound and unbound contexts.
|
|
114
|
+
*/
|
|
88
115
|
public get(id: string): FluidDataStoreContext | undefined {
|
|
89
116
|
return this._contexts.get(id);
|
|
90
117
|
}
|
|
91
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Deletes the context with the given ID from all internal maps.
|
|
121
|
+
* @returns True if the context was found and deleted, false otherwise.
|
|
122
|
+
*/
|
|
92
123
|
public delete(id: string): boolean {
|
|
93
124
|
this.deferredContexts.delete(id);
|
|
94
125
|
this.notBoundContexts.delete(id);
|
|
@@ -100,16 +131,24 @@ export class DataStoreContexts
|
|
|
100
131
|
return this._contexts.delete(id);
|
|
101
132
|
}
|
|
102
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Map of recently deleted contexts for diagnostic purposes for GC.
|
|
136
|
+
* Allows retrieval of context information even after deletion for logging/telemetry.
|
|
137
|
+
*/
|
|
103
138
|
private readonly _recentlyDeletedContexts: Map<string, FluidDataStoreContext | undefined> =
|
|
104
139
|
new Map();
|
|
105
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Returns a recently deleted context by ID, or undefined if not found.
|
|
143
|
+
* Used for diagnostic logging for GC, when a deleted context is referenced.
|
|
144
|
+
*/
|
|
106
145
|
public getRecentlyDeletedContext(id: string): FluidDataStoreContext | undefined {
|
|
107
146
|
return this._recentlyDeletedContexts.get(id);
|
|
108
147
|
}
|
|
109
148
|
|
|
110
149
|
/**
|
|
111
|
-
*
|
|
112
|
-
* or undefined if
|
|
150
|
+
* Returns the unbound local context with the given ID.
|
|
151
|
+
* @returns The unbound context, or undefined if not found or not unbound.
|
|
113
152
|
*/
|
|
114
153
|
public getUnbound(id: string): LocalFluidDataStoreContext | undefined {
|
|
115
154
|
const context = this._contexts.get(id);
|
|
@@ -121,7 +160,8 @@ export class DataStoreContexts
|
|
|
121
160
|
}
|
|
122
161
|
|
|
123
162
|
/**
|
|
124
|
-
*
|
|
163
|
+
* Adds the given context to the collection, marking it as unbound (not yet locally visible).
|
|
164
|
+
* Asserts that no context with this ID already exists.
|
|
125
165
|
*/
|
|
126
166
|
public addUnbound(context: LocalFluidDataStoreContext): void {
|
|
127
167
|
const id = context.id;
|
|
@@ -152,6 +192,10 @@ export class DataStoreContexts
|
|
|
152
192
|
return deferredContext.promise;
|
|
153
193
|
}
|
|
154
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Gets or creates a deferred promise for the given context ID.
|
|
197
|
+
* Used to allow waiting for contexts that don't exist yet.
|
|
198
|
+
*/
|
|
155
199
|
private ensureDeferred(id: string): Deferred<FluidDataStoreContext> {
|
|
156
200
|
const deferred = this.deferredContexts.get(id);
|
|
157
201
|
if (deferred) {
|
|
@@ -164,7 +208,8 @@ export class DataStoreContexts
|
|
|
164
208
|
}
|
|
165
209
|
|
|
166
210
|
/**
|
|
167
|
-
*
|
|
211
|
+
* Marks the context with the given ID as bound (locally visible).
|
|
212
|
+
* Removes it from the unbound set and resolves its deferred promise.
|
|
168
213
|
*/
|
|
169
214
|
public bind(id: string): void {
|
|
170
215
|
const removed: boolean = this.notBoundContexts.delete(id);
|
|
@@ -191,9 +236,11 @@ export class DataStoreContexts
|
|
|
191
236
|
}
|
|
192
237
|
|
|
193
238
|
/**
|
|
194
|
-
*
|
|
195
|
-
* This
|
|
196
|
-
*
|
|
239
|
+
* Adds the given context to the collection as already bound or from a remote client.
|
|
240
|
+
* This is used when:
|
|
241
|
+
* - Adding a local context that's already been bound via the bind() method, OR
|
|
242
|
+
* - Adding a remote context that was created by another client.
|
|
243
|
+
* The context's deferred promise is resolved immediately.
|
|
197
244
|
*/
|
|
198
245
|
public addBoundOrRemoted(context: FluidDataStoreContext): void {
|
|
199
246
|
const id = context.id;
|
package/src/packageVersion.ts
CHANGED