@fluid-experimental/oldest-client-observer 2.0.0-dev.7.4.0.215930 → 2.0.0-dev.7.4.0.216897
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/api-extractor-lint.json +13 -0
- package/api-report/oldest-client-observer.api.md +5 -5
- package/dist/interfaces.cjs.map +1 -1
- package/dist/interfaces.d.ts +4 -7
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/oldest-client-observer-alpha.d.ts +11 -106
- package/dist/oldest-client-observer-beta.d.ts +11 -106
- package/dist/oldest-client-observer-public.d.ts +11 -106
- package/dist/oldest-client-observer-untrimmed.d.ts +5 -9
- package/dist/oldestClientObserver.cjs +1 -2
- package/dist/oldestClientObserver.cjs.map +1 -1
- package/dist/oldestClientObserver.d.ts +1 -2
- package/dist/oldestClientObserver.d.ts.map +1 -1
- package/lib/interfaces.d.ts +4 -7
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.mjs.map +1 -1
- package/lib/oldest-client-observer-alpha.d.ts +11 -106
- package/lib/oldest-client-observer-beta.d.ts +11 -106
- package/lib/oldest-client-observer-public.d.ts +11 -106
- package/lib/oldest-client-observer-untrimmed.d.ts +5 -9
- package/lib/oldestClientObserver.d.ts +1 -2
- package/lib/oldestClientObserver.d.ts.map +1 -1
- package/lib/oldestClientObserver.mjs +1 -2
- package/lib/oldestClientObserver.mjs.map +1 -1
- package/package.json +9 -8
- package/src/interfaces.ts +4 -7
- package/src/oldestClientObserver.ts +1 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-lint.json",
|
|
4
|
+
"messages": {
|
|
5
|
+
"extractorMessageReporting": {
|
|
6
|
+
// TODO: remove once base config has this enabled as an error
|
|
7
|
+
"ae-incompatible-release-tags": {
|
|
8
|
+
"logLevel": "error",
|
|
9
|
+
"addToApiReportFile": false
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -10,7 +10,7 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
|
10
10
|
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
11
11
|
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
12
12
|
|
|
13
|
-
// @
|
|
13
|
+
// @internal
|
|
14
14
|
export interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
15
15
|
// (undocumented)
|
|
16
16
|
attachState: AttachState;
|
|
@@ -22,7 +22,7 @@ export interface IOldestClientObservable extends IEventProvider<IOldestClientObs
|
|
|
22
22
|
getQuorum(): IQuorumClients;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// @
|
|
25
|
+
// @internal
|
|
26
26
|
export interface IOldestClientObservableEvents extends IEvent {
|
|
27
27
|
// (undocumented)
|
|
28
28
|
(event: "connected", listener: () => void): any;
|
|
@@ -30,19 +30,19 @@ export interface IOldestClientObservableEvents extends IEvent {
|
|
|
30
30
|
(event: "disconnected", listener: () => void): any;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// @
|
|
33
|
+
// @internal (undocumented)
|
|
34
34
|
export interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
35
|
// (undocumented)
|
|
36
36
|
isOldest(): boolean;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
// @
|
|
39
|
+
// @internal
|
|
40
40
|
export interface IOldestClientObserverEvents extends IEvent {
|
|
41
41
|
// (undocumented)
|
|
42
42
|
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// @
|
|
45
|
+
// @internal
|
|
46
46
|
export class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
47
47
|
constructor(observable: IOldestClientObservable);
|
|
48
48
|
// (undocumented)
|
package/dist/interfaces.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.cjs","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Events emitted by {@link IOldestClientObservable}.\n
|
|
1
|
+
{"version":3,"file":"interfaces.cjs","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Events emitted by {@link IOldestClientObservable}.\n * @internal\n */\nexport interface IOldestClientObservableEvents extends IEvent {\n\t(event: \"connected\", listener: () => void);\n\t(event: \"disconnected\", listener: () => void);\n}\n\n/**\n * This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime\n * (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,\n * since neither is really the source of truth (they are just the only currently-available plumbing options).\n * It's information about the connection, so the real source of truth is lower (at the connection layer).\n * @internal\n */\nexport interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {\n\tgetQuorum(): IQuorumClients;\n\t// Generic usage of attachState is a little unusual here. We will treat ourselves as \"the oldest client that\n\t// has information about this [container | data store]\", which in the case of detached data store may disagree\n\t// with whether we're the oldest client on the connected container. So in the data store case, it's only\n\t// safe use this as an indicator about rights to tasks performed against this specific data store, and not\n\t// more broadly.\n\tattachState: AttachState;\n\tconnected: boolean;\n\tclientId: string | undefined;\n}\n\n/**\n * Events emitted by {@link IOldestClientObservable}.\n * @internal\n */\nexport interface IOldestClientObserverEvents extends IEvent {\n\t(event: \"becameOldest\" | \"lostOldest\", listener: () => void);\n}\n\n/**\n * @internal\n */\nexport interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {\n\tisOldest(): boolean;\n}\n"]}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ import { AttachState } from "@fluidframework/container-definitions";
|
|
|
7
7
|
import { IQuorumClients } from "@fluidframework/protocol-definitions";
|
|
8
8
|
/**
|
|
9
9
|
* Events emitted by {@link IOldestClientObservable}.
|
|
10
|
-
*
|
|
11
|
-
* @public
|
|
10
|
+
* @internal
|
|
12
11
|
*/
|
|
13
12
|
export interface IOldestClientObservableEvents extends IEvent {
|
|
14
13
|
(event: "connected", listener: () => void): any;
|
|
@@ -19,8 +18,7 @@ export interface IOldestClientObservableEvents extends IEvent {
|
|
|
19
18
|
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
20
19
|
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
21
20
|
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
22
|
-
*
|
|
23
|
-
* @public
|
|
21
|
+
* @internal
|
|
24
22
|
*/
|
|
25
23
|
export interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
26
24
|
getQuorum(): IQuorumClients;
|
|
@@ -30,14 +28,13 @@ export interface IOldestClientObservable extends IEventProvider<IOldestClientObs
|
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
30
|
* Events emitted by {@link IOldestClientObservable}.
|
|
33
|
-
*
|
|
34
|
-
* @public
|
|
31
|
+
* @internal
|
|
35
32
|
*/
|
|
36
33
|
export interface IOldestClientObserverEvents extends IEvent {
|
|
37
34
|
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
38
35
|
}
|
|
39
36
|
/**
|
|
40
|
-
* @
|
|
37
|
+
* @internal
|
|
41
38
|
*/
|
|
42
39
|
export interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
43
40
|
isOldest(): boolean;
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,MAAM;IAC5D,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;IAC3C,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CAC9C;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAwB,SAAQ,cAAc,CAAC,6BAA6B,CAAC;IAC7F,SAAS,IAAI,cAAc,CAAC;IAM5B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA4B,SAAQ,MAAM;IAC1D,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CAC7D;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,2BAA2B,CAAC;IACzF,QAAQ,IAAI,OAAO,CAAC;CACpB"}
|
|
@@ -1,115 +1,20 @@
|
|
|
1
|
-
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
-
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
-
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
1
|
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
* This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime
|
|
8
|
-
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
9
|
-
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
10
|
-
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
15
|
-
getQuorum(): IQuorumClients;
|
|
16
|
-
attachState: AttachState;
|
|
17
|
-
connected: boolean;
|
|
18
|
-
clientId: string | undefined;
|
|
19
|
-
}
|
|
3
|
+
/* Excluded from this release type: AttachState */
|
|
20
4
|
|
|
21
|
-
|
|
22
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
27
|
-
(event: "connected", listener: () => void): any;
|
|
28
|
-
(event: "disconnected", listener: () => void): any;
|
|
29
|
-
}
|
|
5
|
+
/* Excluded from this release type: IEvent */
|
|
30
6
|
|
|
31
|
-
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
-
isOldest(): boolean;
|
|
36
|
-
}
|
|
7
|
+
/* Excluded from this release type: IEventProvider */
|
|
37
8
|
|
|
38
|
-
|
|
39
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
44
|
-
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
45
|
-
}
|
|
9
|
+
/* Excluded from this release type: IOldestClientObservable */
|
|
46
10
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* ### Creation
|
|
55
|
-
*
|
|
56
|
-
* The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with
|
|
57
|
-
* either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:
|
|
58
|
-
*
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // E.g. from within a BaseContainerRuntimeFactory:
|
|
61
|
-
* protected async containerHasInitialized(runtime: IContainerRuntime) {
|
|
62
|
-
* const oldestClientObserver = new OldestClientObserver(runtime);
|
|
63
|
-
* // ...
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* ```typescript
|
|
68
|
-
* // From within a DataObject
|
|
69
|
-
* protected async hasInitialized() {
|
|
70
|
-
* const oldestClientObserver = new OldestClientObserver(this.runtime);
|
|
71
|
-
* // ...
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* ### Usage
|
|
76
|
-
*
|
|
77
|
-
* To check if the local client is the oldest, use the `isOldest()` method.
|
|
78
|
-
*
|
|
79
|
-
* ```typescript
|
|
80
|
-
* if (oldestClientObserver.isOldest()) {
|
|
81
|
-
* console.log("I'm the oldest");
|
|
82
|
-
* } else {
|
|
83
|
-
* console.log("Someone else is older");
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* ### Eventing
|
|
88
|
-
*
|
|
89
|
-
* `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when
|
|
90
|
-
* it is no longer the oldest.
|
|
91
|
-
*
|
|
92
|
-
* ```typescript
|
|
93
|
-
* oldestClientObserver.on("becameOldest", () => {
|
|
94
|
-
* console.log("I'm the oldest now");
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* oldestClientObserver.on("lostOldest", () => {
|
|
98
|
-
* console.log("I'm not the oldest anymore");
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
105
|
-
private readonly observable;
|
|
106
|
-
private readonly quorum;
|
|
107
|
-
private currentIsOldest;
|
|
108
|
-
constructor(observable: IOldestClientObservable);
|
|
109
|
-
isOldest(): boolean;
|
|
110
|
-
private readonly updateOldest;
|
|
111
|
-
private computeIsOldest;
|
|
112
|
-
}
|
|
11
|
+
/* Excluded from this release type: IOldestClientObservableEvents */
|
|
12
|
+
|
|
13
|
+
/* Excluded from this release type: IOldestClientObserver */
|
|
14
|
+
|
|
15
|
+
/* Excluded from this release type: IOldestClientObserverEvents */
|
|
16
|
+
|
|
17
|
+
/* Excluded from this release type: OldestClientObserver */
|
|
113
18
|
|
|
114
19
|
/* Excluded from this release type: TypedEventEmitter */
|
|
115
20
|
|
|
@@ -1,115 +1,20 @@
|
|
|
1
|
-
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
-
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
-
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
1
|
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
* This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime
|
|
8
|
-
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
9
|
-
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
10
|
-
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
15
|
-
getQuorum(): IQuorumClients;
|
|
16
|
-
attachState: AttachState;
|
|
17
|
-
connected: boolean;
|
|
18
|
-
clientId: string | undefined;
|
|
19
|
-
}
|
|
3
|
+
/* Excluded from this release type: AttachState */
|
|
20
4
|
|
|
21
|
-
|
|
22
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
27
|
-
(event: "connected", listener: () => void): any;
|
|
28
|
-
(event: "disconnected", listener: () => void): any;
|
|
29
|
-
}
|
|
5
|
+
/* Excluded from this release type: IEvent */
|
|
30
6
|
|
|
31
|
-
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
-
isOldest(): boolean;
|
|
36
|
-
}
|
|
7
|
+
/* Excluded from this release type: IEventProvider */
|
|
37
8
|
|
|
38
|
-
|
|
39
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
44
|
-
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
45
|
-
}
|
|
9
|
+
/* Excluded from this release type: IOldestClientObservable */
|
|
46
10
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* ### Creation
|
|
55
|
-
*
|
|
56
|
-
* The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with
|
|
57
|
-
* either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:
|
|
58
|
-
*
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // E.g. from within a BaseContainerRuntimeFactory:
|
|
61
|
-
* protected async containerHasInitialized(runtime: IContainerRuntime) {
|
|
62
|
-
* const oldestClientObserver = new OldestClientObserver(runtime);
|
|
63
|
-
* // ...
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* ```typescript
|
|
68
|
-
* // From within a DataObject
|
|
69
|
-
* protected async hasInitialized() {
|
|
70
|
-
* const oldestClientObserver = new OldestClientObserver(this.runtime);
|
|
71
|
-
* // ...
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* ### Usage
|
|
76
|
-
*
|
|
77
|
-
* To check if the local client is the oldest, use the `isOldest()` method.
|
|
78
|
-
*
|
|
79
|
-
* ```typescript
|
|
80
|
-
* if (oldestClientObserver.isOldest()) {
|
|
81
|
-
* console.log("I'm the oldest");
|
|
82
|
-
* } else {
|
|
83
|
-
* console.log("Someone else is older");
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* ### Eventing
|
|
88
|
-
*
|
|
89
|
-
* `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when
|
|
90
|
-
* it is no longer the oldest.
|
|
91
|
-
*
|
|
92
|
-
* ```typescript
|
|
93
|
-
* oldestClientObserver.on("becameOldest", () => {
|
|
94
|
-
* console.log("I'm the oldest now");
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* oldestClientObserver.on("lostOldest", () => {
|
|
98
|
-
* console.log("I'm not the oldest anymore");
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
105
|
-
private readonly observable;
|
|
106
|
-
private readonly quorum;
|
|
107
|
-
private currentIsOldest;
|
|
108
|
-
constructor(observable: IOldestClientObservable);
|
|
109
|
-
isOldest(): boolean;
|
|
110
|
-
private readonly updateOldest;
|
|
111
|
-
private computeIsOldest;
|
|
112
|
-
}
|
|
11
|
+
/* Excluded from this release type: IOldestClientObservableEvents */
|
|
12
|
+
|
|
13
|
+
/* Excluded from this release type: IOldestClientObserver */
|
|
14
|
+
|
|
15
|
+
/* Excluded from this release type: IOldestClientObserverEvents */
|
|
16
|
+
|
|
17
|
+
/* Excluded from this release type: OldestClientObserver */
|
|
113
18
|
|
|
114
19
|
/* Excluded from this release type: TypedEventEmitter */
|
|
115
20
|
|
|
@@ -1,115 +1,20 @@
|
|
|
1
|
-
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
-
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
-
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
1
|
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
* This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime
|
|
8
|
-
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
9
|
-
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
10
|
-
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
15
|
-
getQuorum(): IQuorumClients;
|
|
16
|
-
attachState: AttachState;
|
|
17
|
-
connected: boolean;
|
|
18
|
-
clientId: string | undefined;
|
|
19
|
-
}
|
|
3
|
+
/* Excluded from this release type: AttachState */
|
|
20
4
|
|
|
21
|
-
|
|
22
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
27
|
-
(event: "connected", listener: () => void): any;
|
|
28
|
-
(event: "disconnected", listener: () => void): any;
|
|
29
|
-
}
|
|
5
|
+
/* Excluded from this release type: IEvent */
|
|
30
6
|
|
|
31
|
-
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
-
isOldest(): boolean;
|
|
36
|
-
}
|
|
7
|
+
/* Excluded from this release type: IEventProvider */
|
|
37
8
|
|
|
38
|
-
|
|
39
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
44
|
-
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
45
|
-
}
|
|
9
|
+
/* Excluded from this release type: IOldestClientObservable */
|
|
46
10
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* ### Creation
|
|
55
|
-
*
|
|
56
|
-
* The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with
|
|
57
|
-
* either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:
|
|
58
|
-
*
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // E.g. from within a BaseContainerRuntimeFactory:
|
|
61
|
-
* protected async containerHasInitialized(runtime: IContainerRuntime) {
|
|
62
|
-
* const oldestClientObserver = new OldestClientObserver(runtime);
|
|
63
|
-
* // ...
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* ```typescript
|
|
68
|
-
* // From within a DataObject
|
|
69
|
-
* protected async hasInitialized() {
|
|
70
|
-
* const oldestClientObserver = new OldestClientObserver(this.runtime);
|
|
71
|
-
* // ...
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* ### Usage
|
|
76
|
-
*
|
|
77
|
-
* To check if the local client is the oldest, use the `isOldest()` method.
|
|
78
|
-
*
|
|
79
|
-
* ```typescript
|
|
80
|
-
* if (oldestClientObserver.isOldest()) {
|
|
81
|
-
* console.log("I'm the oldest");
|
|
82
|
-
* } else {
|
|
83
|
-
* console.log("Someone else is older");
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* ### Eventing
|
|
88
|
-
*
|
|
89
|
-
* `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when
|
|
90
|
-
* it is no longer the oldest.
|
|
91
|
-
*
|
|
92
|
-
* ```typescript
|
|
93
|
-
* oldestClientObserver.on("becameOldest", () => {
|
|
94
|
-
* console.log("I'm the oldest now");
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* oldestClientObserver.on("lostOldest", () => {
|
|
98
|
-
* console.log("I'm not the oldest anymore");
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
105
|
-
private readonly observable;
|
|
106
|
-
private readonly quorum;
|
|
107
|
-
private currentIsOldest;
|
|
108
|
-
constructor(observable: IOldestClientObservable);
|
|
109
|
-
isOldest(): boolean;
|
|
110
|
-
private readonly updateOldest;
|
|
111
|
-
private computeIsOldest;
|
|
112
|
-
}
|
|
11
|
+
/* Excluded from this release type: IOldestClientObservableEvents */
|
|
12
|
+
|
|
13
|
+
/* Excluded from this release type: IOldestClientObserver */
|
|
14
|
+
|
|
15
|
+
/* Excluded from this release type: IOldestClientObserverEvents */
|
|
16
|
+
|
|
17
|
+
/* Excluded from this release type: OldestClientObserver */
|
|
113
18
|
|
|
114
19
|
/* Excluded from this release type: TypedEventEmitter */
|
|
115
20
|
|
|
@@ -9,8 +9,7 @@ import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
|
9
9
|
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
10
10
|
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
11
11
|
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
12
|
+
* @internal
|
|
14
13
|
*/
|
|
15
14
|
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
16
15
|
getQuorum(): IQuorumClients;
|
|
@@ -21,8 +20,7 @@ export declare interface IOldestClientObservable extends IEventProvider<IOldestC
|
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Events emitted by {@link IOldestClientObservable}.
|
|
24
|
-
*
|
|
25
|
-
* @public
|
|
23
|
+
* @internal
|
|
26
24
|
*/
|
|
27
25
|
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
28
26
|
(event: "connected", listener: () => void): any;
|
|
@@ -30,7 +28,7 @@ export declare interface IOldestClientObservableEvents extends IEvent {
|
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
|
-
* @
|
|
31
|
+
* @internal
|
|
34
32
|
*/
|
|
35
33
|
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
36
34
|
isOldest(): boolean;
|
|
@@ -38,8 +36,7 @@ export declare interface IOldestClientObserver extends IEventProvider<IOldestCli
|
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
38
|
* Events emitted by {@link IOldestClientObservable}.
|
|
41
|
-
*
|
|
42
|
-
* @public
|
|
39
|
+
* @internal
|
|
43
40
|
*/
|
|
44
41
|
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
45
42
|
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
@@ -99,8 +96,7 @@ export declare interface IOldestClientObserverEvents extends IEvent {
|
|
|
99
96
|
* console.log("I'm not the oldest anymore");
|
|
100
97
|
* });
|
|
101
98
|
* ```
|
|
102
|
-
*
|
|
103
|
-
* @public
|
|
99
|
+
* @internal
|
|
104
100
|
*/
|
|
105
101
|
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
106
102
|
private readonly observable;
|
|
@@ -62,8 +62,7 @@ const container_definitions_1 = require("@fluidframework/container-definitions")
|
|
|
62
62
|
* console.log("I'm not the oldest anymore");
|
|
63
63
|
* });
|
|
64
64
|
* ```
|
|
65
|
-
*
|
|
66
|
-
* @public
|
|
65
|
+
* @internal
|
|
67
66
|
*/
|
|
68
67
|
class OldestClientObserver extends client_utils_1.TypedEventEmitter {
|
|
69
68
|
constructor(observable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.cjs","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,2DAAoD;AACpD,iFAAoE;AAQpE
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.cjs","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,2DAAoD;AACpD,iFAAoE;AAQpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAa,oBACZ,SAAQ,gCAA8C;IAKtD,YAA6B,UAAmC;QAC/D,KAAK,EAAE,CAAC;QADoB,eAAU,GAAV,UAAU,CAAyB;QADxD,oBAAe,GAAY,KAAK,CAAC;QAexB,iBAAY,GAAG,GAAS,EAAE;YAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,eAAe,KAAK,MAAM,EAAE;gBACpC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;gBAC9B,IAAI,MAAM,EAAE;oBACX,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;iBAC1B;qBAAM;oBACN,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBACxB;aACD;QACF,CAAC,CAAC;QAtBD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAClD,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAcO,eAAe;QACtB,uGAAuG;QACvG,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,KAAK,mCAAW,CAAC,QAAQ,EAAE;YACzD,OAAO,IAAI,CAAC;SACZ;QAED,kEAAkE;QAClE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;YAC/B,OAAO,KAAK,CAAC;SACb;QAED,yDAAyD;QACzD,IAAA,mBAAM,EACL,IAAI,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS;QACtC,4DAA4D;QAC5D,KAAK,CAAC,4CAA4C,CAClD,CAAC;QAEF,MAAM,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5E,wEAAwE;QACxE,IAAI,mBAAmB,KAAK,SAAS,EAAE;YACtC,OAAO,KAAK,CAAC;SACb;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACzC,KAAK,MAAM,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE;YAC/C,IAAI,eAAe,CAAC,cAAc,GAAG,mBAAmB,CAAC,cAAc,EAAE;gBACxE,OAAO,KAAK,CAAC;aACb;SACD;QAED,oCAAoC;QACpC,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAlED,oDAkEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIOldestClientObservable,\n\tIOldestClientObserverEvents,\n\tIOldestClientObserver,\n} from \"./interfaces\";\n\n/**\n * The `OldestClientObserver` is a utility inspect if the local client is the oldest amongst connected clients (in\n * terms of when they connected) and watch for changes.\n *\n * It is still experimental and under development. Please do try it out, but expect breaking changes in the future.\n *\n * @remarks\n * ### Creation\n *\n * The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with\n * either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:\n *\n * ```typescript\n * // E.g. from within a BaseContainerRuntimeFactory:\n * protected async containerHasInitialized(runtime: IContainerRuntime) {\n * const oldestClientObserver = new OldestClientObserver(runtime);\n * // ...\n * }\n * ```\n *\n * ```typescript\n * // From within a DataObject\n * protected async hasInitialized() {\n * const oldestClientObserver = new OldestClientObserver(this.runtime);\n * // ...\n * }\n * ```\n *\n * ### Usage\n *\n * To check if the local client is the oldest, use the `isOldest()` method.\n *\n * ```typescript\n * if (oldestClientObserver.isOldest()) {\n * console.log(\"I'm the oldest\");\n * } else {\n * console.log(\"Someone else is older\");\n * }\n * ```\n *\n * ### Eventing\n *\n * `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when\n * it is no longer the oldest.\n *\n * ```typescript\n * oldestClientObserver.on(\"becameOldest\", () => {\n * console.log(\"I'm the oldest now\");\n * });\n *\n * oldestClientObserver.on(\"lostOldest\", () => {\n * console.log(\"I'm not the oldest anymore\");\n * });\n * ```\n * @internal\n */\nexport class OldestClientObserver\n\textends TypedEventEmitter<IOldestClientObserverEvents>\n\timplements IOldestClientObserver\n{\n\tprivate readonly quorum: IQuorumClients;\n\tprivate currentIsOldest: boolean = false;\n\tconstructor(private readonly observable: IOldestClientObservable) {\n\t\tsuper();\n\t\tthis.quorum = this.observable.getQuorum();\n\t\tthis.currentIsOldest = this.computeIsOldest();\n\t\tthis.quorum.on(\"addMember\", this.updateOldest);\n\t\tthis.quorum.on(\"removeMember\", this.updateOldest);\n\t\tobservable.on(\"connected\", this.updateOldest);\n\t\tobservable.on(\"disconnected\", this.updateOldest);\n\t}\n\n\tpublic isOldest(): boolean {\n\t\treturn this.currentIsOldest;\n\t}\n\n\tprivate readonly updateOldest = (): void => {\n\t\tconst oldest = this.computeIsOldest();\n\t\tif (this.currentIsOldest !== oldest) {\n\t\t\tthis.currentIsOldest = oldest;\n\t\t\tif (oldest) {\n\t\t\t\tthis.emit(\"becameOldest\");\n\t\t\t} else {\n\t\t\t\tthis.emit(\"lostOldest\");\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate computeIsOldest(): boolean {\n\t\t// If the container is detached, we are the only ones that know about it and are the oldest by default.\n\t\tif (this.observable.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If we're not connected we can't be the oldest connected client.\n\t\tif (!this.observable.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// TODO: Clean up error code linter violations repo-wide.\n\t\tassert(\n\t\t\tthis.observable.clientId !== undefined,\n\t\t\t// eslint-disable-next-line unicorn/numeric-separators-style\n\t\t\t0x1da /* \"Client id should be set if connected\" */,\n\t\t);\n\n\t\tconst selfSequencedClient = this.quorum.getMember(this.observable.clientId);\n\t\t// When in readonly mode our clientId will not be present in the quorum.\n\t\tif (selfSequencedClient === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst members = this.quorum.getMembers();\n\t\tfor (const sequencedClient of members.values()) {\n\t\t\tif (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// No member of the quorum was older\n\t\treturn true;\n\t}\n}\n"]}
|
|
@@ -58,8 +58,7 @@ import { IOldestClientObservable, IOldestClientObserverEvents, IOldestClientObse
|
|
|
58
58
|
* console.log("I'm not the oldest anymore");
|
|
59
59
|
* });
|
|
60
60
|
* ```
|
|
61
|
-
*
|
|
62
|
-
* @public
|
|
61
|
+
* @internal
|
|
63
62
|
*/
|
|
64
63
|
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
65
64
|
private readonly observable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.d.ts","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAIjE,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,cAAc,CAAC;AAEtB
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.d.ts","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAIjE,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,qBAAa,oBACZ,SAAQ,iBAAiB,CAAC,2BAA2B,CACrD,YAAW,qBAAqB;IAIpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,eAAe,CAAkB;gBACZ,UAAU,EAAE,uBAAuB;IAUzD,QAAQ,IAAI,OAAO;IAI1B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAU3B;IAEF,OAAO,CAAC,eAAe;CAkCvB"}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ import { AttachState } from "@fluidframework/container-definitions";
|
|
|
7
7
|
import { IQuorumClients } from "@fluidframework/protocol-definitions";
|
|
8
8
|
/**
|
|
9
9
|
* Events emitted by {@link IOldestClientObservable}.
|
|
10
|
-
*
|
|
11
|
-
* @public
|
|
10
|
+
* @internal
|
|
12
11
|
*/
|
|
13
12
|
export interface IOldestClientObservableEvents extends IEvent {
|
|
14
13
|
(event: "connected", listener: () => void): any;
|
|
@@ -19,8 +18,7 @@ export interface IOldestClientObservableEvents extends IEvent {
|
|
|
19
18
|
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
20
19
|
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
21
20
|
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
22
|
-
*
|
|
23
|
-
* @public
|
|
21
|
+
* @internal
|
|
24
22
|
*/
|
|
25
23
|
export interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
26
24
|
getQuorum(): IQuorumClients;
|
|
@@ -30,14 +28,13 @@ export interface IOldestClientObservable extends IEventProvider<IOldestClientObs
|
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
30
|
* Events emitted by {@link IOldestClientObservable}.
|
|
33
|
-
*
|
|
34
|
-
* @public
|
|
31
|
+
* @internal
|
|
35
32
|
*/
|
|
36
33
|
export interface IOldestClientObserverEvents extends IEvent {
|
|
37
34
|
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
38
35
|
}
|
|
39
36
|
/**
|
|
40
|
-
* @
|
|
37
|
+
* @internal
|
|
41
38
|
*/
|
|
42
39
|
export interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
43
40
|
isOldest(): boolean;
|
package/lib/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,MAAM;IAC5D,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;IAC3C,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CAC9C;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAwB,SAAQ,cAAc,CAAC,6BAA6B,CAAC;IAC7F,SAAS,IAAI,cAAc,CAAC;IAM5B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA4B,SAAQ,MAAM;IAC1D,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CAC7D;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,2BAA2B,CAAC;IACzF,QAAQ,IAAI,OAAO,CAAC;CACpB"}
|
package/lib/interfaces.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.mjs","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Events emitted by {@link IOldestClientObservable}.\n
|
|
1
|
+
{"version":3,"file":"interfaces.mjs","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Events emitted by {@link IOldestClientObservable}.\n * @internal\n */\nexport interface IOldestClientObservableEvents extends IEvent {\n\t(event: \"connected\", listener: () => void);\n\t(event: \"disconnected\", listener: () => void);\n}\n\n/**\n * This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime\n * (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,\n * since neither is really the source of truth (they are just the only currently-available plumbing options).\n * It's information about the connection, so the real source of truth is lower (at the connection layer).\n * @internal\n */\nexport interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {\n\tgetQuorum(): IQuorumClients;\n\t// Generic usage of attachState is a little unusual here. We will treat ourselves as \"the oldest client that\n\t// has information about this [container | data store]\", which in the case of detached data store may disagree\n\t// with whether we're the oldest client on the connected container. So in the data store case, it's only\n\t// safe use this as an indicator about rights to tasks performed against this specific data store, and not\n\t// more broadly.\n\tattachState: AttachState;\n\tconnected: boolean;\n\tclientId: string | undefined;\n}\n\n/**\n * Events emitted by {@link IOldestClientObservable}.\n * @internal\n */\nexport interface IOldestClientObserverEvents extends IEvent {\n\t(event: \"becameOldest\" | \"lostOldest\", listener: () => void);\n}\n\n/**\n * @internal\n */\nexport interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {\n\tisOldest(): boolean;\n}\n"]}
|
|
@@ -1,115 +1,20 @@
|
|
|
1
|
-
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
-
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
-
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
1
|
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
* This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime
|
|
8
|
-
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
9
|
-
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
10
|
-
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
15
|
-
getQuorum(): IQuorumClients;
|
|
16
|
-
attachState: AttachState;
|
|
17
|
-
connected: boolean;
|
|
18
|
-
clientId: string | undefined;
|
|
19
|
-
}
|
|
3
|
+
/* Excluded from this release type: AttachState */
|
|
20
4
|
|
|
21
|
-
|
|
22
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
27
|
-
(event: "connected", listener: () => void): any;
|
|
28
|
-
(event: "disconnected", listener: () => void): any;
|
|
29
|
-
}
|
|
5
|
+
/* Excluded from this release type: IEvent */
|
|
30
6
|
|
|
31
|
-
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
-
isOldest(): boolean;
|
|
36
|
-
}
|
|
7
|
+
/* Excluded from this release type: IEventProvider */
|
|
37
8
|
|
|
38
|
-
|
|
39
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
44
|
-
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
45
|
-
}
|
|
9
|
+
/* Excluded from this release type: IOldestClientObservable */
|
|
46
10
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* ### Creation
|
|
55
|
-
*
|
|
56
|
-
* The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with
|
|
57
|
-
* either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:
|
|
58
|
-
*
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // E.g. from within a BaseContainerRuntimeFactory:
|
|
61
|
-
* protected async containerHasInitialized(runtime: IContainerRuntime) {
|
|
62
|
-
* const oldestClientObserver = new OldestClientObserver(runtime);
|
|
63
|
-
* // ...
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* ```typescript
|
|
68
|
-
* // From within a DataObject
|
|
69
|
-
* protected async hasInitialized() {
|
|
70
|
-
* const oldestClientObserver = new OldestClientObserver(this.runtime);
|
|
71
|
-
* // ...
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* ### Usage
|
|
76
|
-
*
|
|
77
|
-
* To check if the local client is the oldest, use the `isOldest()` method.
|
|
78
|
-
*
|
|
79
|
-
* ```typescript
|
|
80
|
-
* if (oldestClientObserver.isOldest()) {
|
|
81
|
-
* console.log("I'm the oldest");
|
|
82
|
-
* } else {
|
|
83
|
-
* console.log("Someone else is older");
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* ### Eventing
|
|
88
|
-
*
|
|
89
|
-
* `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when
|
|
90
|
-
* it is no longer the oldest.
|
|
91
|
-
*
|
|
92
|
-
* ```typescript
|
|
93
|
-
* oldestClientObserver.on("becameOldest", () => {
|
|
94
|
-
* console.log("I'm the oldest now");
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* oldestClientObserver.on("lostOldest", () => {
|
|
98
|
-
* console.log("I'm not the oldest anymore");
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
105
|
-
private readonly observable;
|
|
106
|
-
private readonly quorum;
|
|
107
|
-
private currentIsOldest;
|
|
108
|
-
constructor(observable: IOldestClientObservable);
|
|
109
|
-
isOldest(): boolean;
|
|
110
|
-
private readonly updateOldest;
|
|
111
|
-
private computeIsOldest;
|
|
112
|
-
}
|
|
11
|
+
/* Excluded from this release type: IOldestClientObservableEvents */
|
|
12
|
+
|
|
13
|
+
/* Excluded from this release type: IOldestClientObserver */
|
|
14
|
+
|
|
15
|
+
/* Excluded from this release type: IOldestClientObserverEvents */
|
|
16
|
+
|
|
17
|
+
/* Excluded from this release type: OldestClientObserver */
|
|
113
18
|
|
|
114
19
|
/* Excluded from this release type: TypedEventEmitter */
|
|
115
20
|
|
|
@@ -1,115 +1,20 @@
|
|
|
1
|
-
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
-
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
-
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
1
|
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
* This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime
|
|
8
|
-
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
9
|
-
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
10
|
-
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
15
|
-
getQuorum(): IQuorumClients;
|
|
16
|
-
attachState: AttachState;
|
|
17
|
-
connected: boolean;
|
|
18
|
-
clientId: string | undefined;
|
|
19
|
-
}
|
|
3
|
+
/* Excluded from this release type: AttachState */
|
|
20
4
|
|
|
21
|
-
|
|
22
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
27
|
-
(event: "connected", listener: () => void): any;
|
|
28
|
-
(event: "disconnected", listener: () => void): any;
|
|
29
|
-
}
|
|
5
|
+
/* Excluded from this release type: IEvent */
|
|
30
6
|
|
|
31
|
-
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
-
isOldest(): boolean;
|
|
36
|
-
}
|
|
7
|
+
/* Excluded from this release type: IEventProvider */
|
|
37
8
|
|
|
38
|
-
|
|
39
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
44
|
-
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
45
|
-
}
|
|
9
|
+
/* Excluded from this release type: IOldestClientObservable */
|
|
46
10
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* ### Creation
|
|
55
|
-
*
|
|
56
|
-
* The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with
|
|
57
|
-
* either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:
|
|
58
|
-
*
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // E.g. from within a BaseContainerRuntimeFactory:
|
|
61
|
-
* protected async containerHasInitialized(runtime: IContainerRuntime) {
|
|
62
|
-
* const oldestClientObserver = new OldestClientObserver(runtime);
|
|
63
|
-
* // ...
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* ```typescript
|
|
68
|
-
* // From within a DataObject
|
|
69
|
-
* protected async hasInitialized() {
|
|
70
|
-
* const oldestClientObserver = new OldestClientObserver(this.runtime);
|
|
71
|
-
* // ...
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* ### Usage
|
|
76
|
-
*
|
|
77
|
-
* To check if the local client is the oldest, use the `isOldest()` method.
|
|
78
|
-
*
|
|
79
|
-
* ```typescript
|
|
80
|
-
* if (oldestClientObserver.isOldest()) {
|
|
81
|
-
* console.log("I'm the oldest");
|
|
82
|
-
* } else {
|
|
83
|
-
* console.log("Someone else is older");
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* ### Eventing
|
|
88
|
-
*
|
|
89
|
-
* `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when
|
|
90
|
-
* it is no longer the oldest.
|
|
91
|
-
*
|
|
92
|
-
* ```typescript
|
|
93
|
-
* oldestClientObserver.on("becameOldest", () => {
|
|
94
|
-
* console.log("I'm the oldest now");
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* oldestClientObserver.on("lostOldest", () => {
|
|
98
|
-
* console.log("I'm not the oldest anymore");
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
105
|
-
private readonly observable;
|
|
106
|
-
private readonly quorum;
|
|
107
|
-
private currentIsOldest;
|
|
108
|
-
constructor(observable: IOldestClientObservable);
|
|
109
|
-
isOldest(): boolean;
|
|
110
|
-
private readonly updateOldest;
|
|
111
|
-
private computeIsOldest;
|
|
112
|
-
}
|
|
11
|
+
/* Excluded from this release type: IOldestClientObservableEvents */
|
|
12
|
+
|
|
13
|
+
/* Excluded from this release type: IOldestClientObserver */
|
|
14
|
+
|
|
15
|
+
/* Excluded from this release type: IOldestClientObserverEvents */
|
|
16
|
+
|
|
17
|
+
/* Excluded from this release type: OldestClientObserver */
|
|
113
18
|
|
|
114
19
|
/* Excluded from this release type: TypedEventEmitter */
|
|
115
20
|
|
|
@@ -1,115 +1,20 @@
|
|
|
1
|
-
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
-
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
-
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
1
|
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
* This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime
|
|
8
|
-
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
9
|
-
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
10
|
-
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
15
|
-
getQuorum(): IQuorumClients;
|
|
16
|
-
attachState: AttachState;
|
|
17
|
-
connected: boolean;
|
|
18
|
-
clientId: string | undefined;
|
|
19
|
-
}
|
|
3
|
+
/* Excluded from this release type: AttachState */
|
|
20
4
|
|
|
21
|
-
|
|
22
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
27
|
-
(event: "connected", listener: () => void): any;
|
|
28
|
-
(event: "disconnected", listener: () => void): any;
|
|
29
|
-
}
|
|
5
|
+
/* Excluded from this release type: IEvent */
|
|
30
6
|
|
|
31
|
-
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
-
isOldest(): boolean;
|
|
36
|
-
}
|
|
7
|
+
/* Excluded from this release type: IEventProvider */
|
|
37
8
|
|
|
38
|
-
|
|
39
|
-
* Events emitted by {@link IOldestClientObservable}.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
44
|
-
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
45
|
-
}
|
|
9
|
+
/* Excluded from this release type: IOldestClientObservable */
|
|
46
10
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* ### Creation
|
|
55
|
-
*
|
|
56
|
-
* The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with
|
|
57
|
-
* either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:
|
|
58
|
-
*
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // E.g. from within a BaseContainerRuntimeFactory:
|
|
61
|
-
* protected async containerHasInitialized(runtime: IContainerRuntime) {
|
|
62
|
-
* const oldestClientObserver = new OldestClientObserver(runtime);
|
|
63
|
-
* // ...
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* ```typescript
|
|
68
|
-
* // From within a DataObject
|
|
69
|
-
* protected async hasInitialized() {
|
|
70
|
-
* const oldestClientObserver = new OldestClientObserver(this.runtime);
|
|
71
|
-
* // ...
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* ### Usage
|
|
76
|
-
*
|
|
77
|
-
* To check if the local client is the oldest, use the `isOldest()` method.
|
|
78
|
-
*
|
|
79
|
-
* ```typescript
|
|
80
|
-
* if (oldestClientObserver.isOldest()) {
|
|
81
|
-
* console.log("I'm the oldest");
|
|
82
|
-
* } else {
|
|
83
|
-
* console.log("Someone else is older");
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* ### Eventing
|
|
88
|
-
*
|
|
89
|
-
* `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when
|
|
90
|
-
* it is no longer the oldest.
|
|
91
|
-
*
|
|
92
|
-
* ```typescript
|
|
93
|
-
* oldestClientObserver.on("becameOldest", () => {
|
|
94
|
-
* console.log("I'm the oldest now");
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* oldestClientObserver.on("lostOldest", () => {
|
|
98
|
-
* console.log("I'm not the oldest anymore");
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
105
|
-
private readonly observable;
|
|
106
|
-
private readonly quorum;
|
|
107
|
-
private currentIsOldest;
|
|
108
|
-
constructor(observable: IOldestClientObservable);
|
|
109
|
-
isOldest(): boolean;
|
|
110
|
-
private readonly updateOldest;
|
|
111
|
-
private computeIsOldest;
|
|
112
|
-
}
|
|
11
|
+
/* Excluded from this release type: IOldestClientObservableEvents */
|
|
12
|
+
|
|
13
|
+
/* Excluded from this release type: IOldestClientObserver */
|
|
14
|
+
|
|
15
|
+
/* Excluded from this release type: IOldestClientObserverEvents */
|
|
16
|
+
|
|
17
|
+
/* Excluded from this release type: OldestClientObserver */
|
|
113
18
|
|
|
114
19
|
/* Excluded from this release type: TypedEventEmitter */
|
|
115
20
|
|
|
@@ -9,8 +9,7 @@ import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
|
9
9
|
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
10
10
|
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
11
11
|
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
12
|
+
* @internal
|
|
14
13
|
*/
|
|
15
14
|
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
16
15
|
getQuorum(): IQuorumClients;
|
|
@@ -21,8 +20,7 @@ export declare interface IOldestClientObservable extends IEventProvider<IOldestC
|
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Events emitted by {@link IOldestClientObservable}.
|
|
24
|
-
*
|
|
25
|
-
* @public
|
|
23
|
+
* @internal
|
|
26
24
|
*/
|
|
27
25
|
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
28
26
|
(event: "connected", listener: () => void): any;
|
|
@@ -30,7 +28,7 @@ export declare interface IOldestClientObservableEvents extends IEvent {
|
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
|
-
* @
|
|
31
|
+
* @internal
|
|
34
32
|
*/
|
|
35
33
|
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
36
34
|
isOldest(): boolean;
|
|
@@ -38,8 +36,7 @@ export declare interface IOldestClientObserver extends IEventProvider<IOldestCli
|
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
38
|
* Events emitted by {@link IOldestClientObservable}.
|
|
41
|
-
*
|
|
42
|
-
* @public
|
|
39
|
+
* @internal
|
|
43
40
|
*/
|
|
44
41
|
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
45
42
|
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
@@ -99,8 +96,7 @@ export declare interface IOldestClientObserverEvents extends IEvent {
|
|
|
99
96
|
* console.log("I'm not the oldest anymore");
|
|
100
97
|
* });
|
|
101
98
|
* ```
|
|
102
|
-
*
|
|
103
|
-
* @public
|
|
99
|
+
* @internal
|
|
104
100
|
*/
|
|
105
101
|
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
106
102
|
private readonly observable;
|
|
@@ -58,8 +58,7 @@ import { IOldestClientObservable, IOldestClientObserverEvents, IOldestClientObse
|
|
|
58
58
|
* console.log("I'm not the oldest anymore");
|
|
59
59
|
* });
|
|
60
60
|
* ```
|
|
61
|
-
*
|
|
62
|
-
* @public
|
|
61
|
+
* @internal
|
|
63
62
|
*/
|
|
64
63
|
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
65
64
|
private readonly observable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.d.ts","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAIjE,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,cAAc,CAAC;AAEtB
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.d.ts","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAIjE,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,qBAAa,oBACZ,SAAQ,iBAAiB,CAAC,2BAA2B,CACrD,YAAW,qBAAqB;IAIpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,eAAe,CAAkB;gBACZ,UAAU,EAAE,uBAAuB;IAUzD,QAAQ,IAAI,OAAO;IAI1B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAU3B;IAEF,OAAO,CAAC,eAAe;CAkCvB"}
|
|
@@ -59,8 +59,7 @@ import { AttachState } from "@fluidframework/container-definitions";
|
|
|
59
59
|
* console.log("I'm not the oldest anymore");
|
|
60
60
|
* });
|
|
61
61
|
* ```
|
|
62
|
-
*
|
|
63
|
-
* @public
|
|
62
|
+
* @internal
|
|
64
63
|
*/
|
|
65
64
|
export class OldestClientObserver extends TypedEventEmitter {
|
|
66
65
|
constructor(observable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.mjs","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B;OACzD,EAAE,MAAM,EAAE,MAAM,4BAA4B;OAC5C,EAAE,WAAW,EAAE,MAAM,uCAAuC;AAQnE
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.mjs","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B;OACzD,EAAE,MAAM,EAAE,MAAM,4BAA4B;OAC5C,EAAE,WAAW,EAAE,MAAM,uCAAuC;AAQnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,OAAO,oBACZ,SAAQ,iBAA8C;IAKtD,YAA6B,UAAmC;QAC/D,KAAK,EAAE,CAAC;QADoB,eAAU,GAAV,UAAU,CAAyB;QADxD,oBAAe,GAAY,KAAK,CAAC;QAexB,iBAAY,GAAG,GAAS,EAAE;YAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,eAAe,KAAK,MAAM,EAAE;gBACpC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;gBAC9B,IAAI,MAAM,EAAE;oBACX,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;iBAC1B;qBAAM;oBACN,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBACxB;aACD;QACF,CAAC,CAAC;QAtBD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAClD,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAcO,eAAe;QACtB,uGAAuG;QACvG,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ,EAAE;YACzD,OAAO,IAAI,CAAC;SACZ;QAED,kEAAkE;QAClE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;YAC/B,OAAO,KAAK,CAAC;SACb;QAED,yDAAyD;QACzD,MAAM,CACL,IAAI,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS;QACtC,4DAA4D;QAC5D,KAAK,CAAC,4CAA4C,CAClD,CAAC;QAEF,MAAM,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5E,wEAAwE;QACxE,IAAI,mBAAmB,KAAK,SAAS,EAAE;YACtC,OAAO,KAAK,CAAC;SACb;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACzC,KAAK,MAAM,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE;YAC/C,IAAI,eAAe,CAAC,cAAc,GAAG,mBAAmB,CAAC,cAAc,EAAE;gBACxE,OAAO,KAAK,CAAC;aACb;SACD;QAED,oCAAoC;QACpC,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIOldestClientObservable,\n\tIOldestClientObserverEvents,\n\tIOldestClientObserver,\n} from \"./interfaces\";\n\n/**\n * The `OldestClientObserver` is a utility inspect if the local client is the oldest amongst connected clients (in\n * terms of when they connected) and watch for changes.\n *\n * It is still experimental and under development. Please do try it out, but expect breaking changes in the future.\n *\n * @remarks\n * ### Creation\n *\n * The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with\n * either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:\n *\n * ```typescript\n * // E.g. from within a BaseContainerRuntimeFactory:\n * protected async containerHasInitialized(runtime: IContainerRuntime) {\n * const oldestClientObserver = new OldestClientObserver(runtime);\n * // ...\n * }\n * ```\n *\n * ```typescript\n * // From within a DataObject\n * protected async hasInitialized() {\n * const oldestClientObserver = new OldestClientObserver(this.runtime);\n * // ...\n * }\n * ```\n *\n * ### Usage\n *\n * To check if the local client is the oldest, use the `isOldest()` method.\n *\n * ```typescript\n * if (oldestClientObserver.isOldest()) {\n * console.log(\"I'm the oldest\");\n * } else {\n * console.log(\"Someone else is older\");\n * }\n * ```\n *\n * ### Eventing\n *\n * `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when\n * it is no longer the oldest.\n *\n * ```typescript\n * oldestClientObserver.on(\"becameOldest\", () => {\n * console.log(\"I'm the oldest now\");\n * });\n *\n * oldestClientObserver.on(\"lostOldest\", () => {\n * console.log(\"I'm not the oldest anymore\");\n * });\n * ```\n * @internal\n */\nexport class OldestClientObserver\n\textends TypedEventEmitter<IOldestClientObserverEvents>\n\timplements IOldestClientObserver\n{\n\tprivate readonly quorum: IQuorumClients;\n\tprivate currentIsOldest: boolean = false;\n\tconstructor(private readonly observable: IOldestClientObservable) {\n\t\tsuper();\n\t\tthis.quorum = this.observable.getQuorum();\n\t\tthis.currentIsOldest = this.computeIsOldest();\n\t\tthis.quorum.on(\"addMember\", this.updateOldest);\n\t\tthis.quorum.on(\"removeMember\", this.updateOldest);\n\t\tobservable.on(\"connected\", this.updateOldest);\n\t\tobservable.on(\"disconnected\", this.updateOldest);\n\t}\n\n\tpublic isOldest(): boolean {\n\t\treturn this.currentIsOldest;\n\t}\n\n\tprivate readonly updateOldest = (): void => {\n\t\tconst oldest = this.computeIsOldest();\n\t\tif (this.currentIsOldest !== oldest) {\n\t\t\tthis.currentIsOldest = oldest;\n\t\t\tif (oldest) {\n\t\t\t\tthis.emit(\"becameOldest\");\n\t\t\t} else {\n\t\t\t\tthis.emit(\"lostOldest\");\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate computeIsOldest(): boolean {\n\t\t// If the container is detached, we are the only ones that know about it and are the oldest by default.\n\t\tif (this.observable.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If we're not connected we can't be the oldest connected client.\n\t\tif (!this.observable.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// TODO: Clean up error code linter violations repo-wide.\n\t\tassert(\n\t\t\tthis.observable.clientId !== undefined,\n\t\t\t// eslint-disable-next-line unicorn/numeric-separators-style\n\t\t\t0x1da /* \"Client id should be set if connected\" */,\n\t\t);\n\n\t\tconst selfSequencedClient = this.quorum.getMember(this.observable.clientId);\n\t\t// When in readonly mode our clientId will not be present in the quorum.\n\t\tif (selfSequencedClient === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst members = this.quorum.getMembers();\n\t\tfor (const sequencedClient of members.values()) {\n\t\t\tif (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// No member of the quorum was older\n\t\treturn true;\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/oldest-client-observer",
|
|
3
|
-
"version": "2.0.0-dev.7.4.0.
|
|
3
|
+
"version": "2.0.0-dev.7.4.0.216897",
|
|
4
4
|
"description": "Data object to determine if the local client is the oldest amongst connected clients",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -47,19 +47,19 @@
|
|
|
47
47
|
"temp-directory": "nyc/.nyc_output"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@fluid-internal/client-utils": "2.0.0-dev.7.4.0.
|
|
51
|
-
"@fluidframework/container-definitions": "2.0.0-dev.7.4.0.
|
|
52
|
-
"@fluidframework/core-interfaces": "2.0.0-dev.7.4.0.
|
|
53
|
-
"@fluidframework/core-utils": "2.0.0-dev.7.4.0.
|
|
50
|
+
"@fluid-internal/client-utils": "2.0.0-dev.7.4.0.216897",
|
|
51
|
+
"@fluidframework/container-definitions": "2.0.0-dev.7.4.0.216897",
|
|
52
|
+
"@fluidframework/core-interfaces": "2.0.0-dev.7.4.0.216897",
|
|
53
|
+
"@fluidframework/core-utils": "2.0.0-dev.7.4.0.216897",
|
|
54
54
|
"@fluidframework/protocol-definitions": "^3.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@fluid-private/test-dds-utils": "2.0.0-dev.7.4.0.
|
|
57
|
+
"@fluid-private/test-dds-utils": "2.0.0-dev.7.4.0.216897",
|
|
58
58
|
"@fluid-tools/build-cli": "^0.28.0",
|
|
59
59
|
"@fluidframework/build-common": "^2.0.3",
|
|
60
60
|
"@fluidframework/build-tools": "^0.28.0",
|
|
61
61
|
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
62
|
-
"@fluidframework/test-runtime-utils": "2.0.0-dev.7.4.0.
|
|
62
|
+
"@fluidframework/test-runtime-utils": "2.0.0-dev.7.4.0.216897",
|
|
63
63
|
"@microsoft/api-extractor": "^7.38.3",
|
|
64
64
|
"@types/node": "^16.18.38",
|
|
65
65
|
"copyfiles": "^2.4.1",
|
|
@@ -99,12 +99,13 @@
|
|
|
99
99
|
"build:compile": "fluid-build . --task compile",
|
|
100
100
|
"build:docs": "fluid-build . --task api",
|
|
101
101
|
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
|
|
102
|
+
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
102
103
|
"ci:build:docs": "api-extractor run",
|
|
103
104
|
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp",
|
|
104
105
|
"eslint": "eslint --format stylish src",
|
|
105
106
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
106
107
|
"format": "npm run prettier:fix",
|
|
107
|
-
"lint": "npm run prettier && npm run eslint",
|
|
108
|
+
"lint": "npm run prettier && npm run check:release-tags && npm run eslint",
|
|
108
109
|
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
109
110
|
"prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
110
111
|
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
package/src/interfaces.ts
CHANGED
|
@@ -9,8 +9,7 @@ import { IQuorumClients } from "@fluidframework/protocol-definitions";
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Events emitted by {@link IOldestClientObservable}.
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
12
|
+
* @internal
|
|
14
13
|
*/
|
|
15
14
|
export interface IOldestClientObservableEvents extends IEvent {
|
|
16
15
|
(event: "connected", listener: () => void);
|
|
@@ -22,8 +21,7 @@ export interface IOldestClientObservableEvents extends IEvent {
|
|
|
22
21
|
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
23
22
|
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
24
23
|
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
25
|
-
*
|
|
26
|
-
* @public
|
|
24
|
+
* @internal
|
|
27
25
|
*/
|
|
28
26
|
export interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
29
27
|
getQuorum(): IQuorumClients;
|
|
@@ -39,15 +37,14 @@ export interface IOldestClientObservable extends IEventProvider<IOldestClientObs
|
|
|
39
37
|
|
|
40
38
|
/**
|
|
41
39
|
* Events emitted by {@link IOldestClientObservable}.
|
|
42
|
-
*
|
|
43
|
-
* @public
|
|
40
|
+
* @internal
|
|
44
41
|
*/
|
|
45
42
|
export interface IOldestClientObserverEvents extends IEvent {
|
|
46
43
|
(event: "becameOldest" | "lostOldest", listener: () => void);
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/**
|
|
50
|
-
* @
|
|
47
|
+
* @internal
|
|
51
48
|
*/
|
|
52
49
|
export interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
53
50
|
isOldest(): boolean;
|