@fluid-experimental/oldest-client-observer 2.0.0-internal.7.0.1 → 2.0.0-internal.7.1.1
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/api-extractor.json +1 -1
- package/api-report/oldest-client-observer.api.md +54 -0
- package/dist/interfaces.d.ts +15 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/oldest-client-observer-alpha.d.ts +116 -0
- package/dist/oldest-client-observer-beta.d.ts +116 -0
- package/dist/oldest-client-observer-public.d.ts +116 -0
- package/dist/oldest-client-observer.d.ts +115 -0
- package/dist/oldestClientObserver.d.ts +2 -0
- package/dist/oldestClientObserver.d.ts.map +1 -1
- package/dist/oldestClientObserver.js +2 -0
- package/dist/oldestClientObserver.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/interfaces.d.ts +15 -0
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/oldestClientObserver.d.ts +2 -0
- package/lib/oldestClientObserver.d.ts.map +1 -1
- package/lib/oldestClientObserver.js +2 -0
- package/lib/oldestClientObserver.js.map +1 -1
- package/package.json +15 -15
- package/src/interfaces.ts +15 -0
- package/src/oldestClientObserver.ts +2 -0
package/CHANGELOG.md
CHANGED
package/api-extractor.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
## API Report File for "@fluid-experimental/oldest-client-observer"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { AttachState } from '@fluidframework/container-definitions';
|
|
8
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
9
|
+
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
10
|
+
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
11
|
+
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
12
|
+
|
|
13
|
+
// @public
|
|
14
|
+
export interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
15
|
+
// (undocumented)
|
|
16
|
+
attachState: AttachState;
|
|
17
|
+
// (undocumented)
|
|
18
|
+
clientId: string | undefined;
|
|
19
|
+
// (undocumented)
|
|
20
|
+
connected: boolean;
|
|
21
|
+
// (undocumented)
|
|
22
|
+
getQuorum(): IQuorumClients;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// @public
|
|
26
|
+
export interface IOldestClientObservableEvents extends IEvent {
|
|
27
|
+
// (undocumented)
|
|
28
|
+
(event: "connected", listener: () => void): any;
|
|
29
|
+
// (undocumented)
|
|
30
|
+
(event: "disconnected", listener: () => void): any;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// @public (undocumented)
|
|
34
|
+
export interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
+
// (undocumented)
|
|
36
|
+
isOldest(): boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// @public
|
|
40
|
+
export interface IOldestClientObserverEvents extends IEvent {
|
|
41
|
+
// (undocumented)
|
|
42
|
+
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// @public
|
|
46
|
+
export class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
47
|
+
constructor(observable: IOldestClientObservable);
|
|
48
|
+
// (undocumented)
|
|
49
|
+
isOldest(): boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// (No @packageDocumentation comment for this package)
|
|
53
|
+
|
|
54
|
+
```
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
import { IEvent, IEventProvider } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
7
7
|
import { IQuorumClients } from "@fluidframework/protocol-definitions";
|
|
8
|
+
/**
|
|
9
|
+
* Events emitted by {@link IOldestClientObservable}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
8
13
|
export interface IOldestClientObservableEvents extends IEvent {
|
|
9
14
|
(event: "connected", listener: () => void): any;
|
|
10
15
|
(event: "disconnected", listener: () => void): any;
|
|
@@ -14,6 +19,8 @@ export interface IOldestClientObservableEvents extends IEvent {
|
|
|
14
19
|
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
15
20
|
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
16
21
|
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
17
24
|
*/
|
|
18
25
|
export interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
19
26
|
getQuorum(): IQuorumClients;
|
|
@@ -21,9 +28,17 @@ export interface IOldestClientObservable extends IEventProvider<IOldestClientObs
|
|
|
21
28
|
connected: boolean;
|
|
22
29
|
clientId: string | undefined;
|
|
23
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Events emitted by {@link IOldestClientObservable}.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
24
36
|
export interface IOldestClientObserverEvents extends IEvent {
|
|
25
37
|
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
26
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
27
42
|
export interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
28
43
|
isOldest(): boolean;
|
|
29
44
|
}
|
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,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
|
|
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;;;;GAIG;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;;;;;;;GAOG;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;;;;GAIG;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/dist/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","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\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 */\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\nexport interface IOldestClientObserverEvents extends IEvent {\n\t(event: \"becameOldest\" | \"lostOldest\", listener: () => void);\n}\n\nexport interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {\n\tisOldest(): boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","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 *\n * @public\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 *\n * @public\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 *\n * @public\n */\nexport interface IOldestClientObserverEvents extends IEvent {\n\t(event: \"becameOldest\" | \"lostOldest\", listener: () => void);\n}\n\n/**\n * @public\n */\nexport interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {\n\tisOldest(): boolean;\n}\n"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
+
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
|
+
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
|
+
|
|
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
|
+
}
|
|
20
|
+
|
|
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
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
+
isOldest(): boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
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
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The `OldestClientObserver` is a utility inspect if the local client is the oldest amongst connected clients (in
|
|
49
|
+
* terms of when they connected) and watch for changes.
|
|
50
|
+
*
|
|
51
|
+
* It is still experimental and under development. Please do try it out, but expect breaking changes in the future.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
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
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Excluded from this release type: TypedEventEmitter */
|
|
115
|
+
|
|
116
|
+
export { }
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
+
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
|
+
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
|
+
|
|
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
|
+
}
|
|
20
|
+
|
|
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
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
+
isOldest(): boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
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
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The `OldestClientObserver` is a utility inspect if the local client is the oldest amongst connected clients (in
|
|
49
|
+
* terms of when they connected) and watch for changes.
|
|
50
|
+
*
|
|
51
|
+
* It is still experimental and under development. Please do try it out, but expect breaking changes in the future.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
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
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Excluded from this release type: TypedEventEmitter */
|
|
115
|
+
|
|
116
|
+
export { }
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
+
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
|
+
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
|
+
|
|
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
|
+
}
|
|
20
|
+
|
|
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
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
35
|
+
isOldest(): boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
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
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The `OldestClientObserver` is a utility inspect if the local client is the oldest amongst connected clients (in
|
|
49
|
+
* terms of when they connected) and watch for changes.
|
|
50
|
+
*
|
|
51
|
+
* It is still experimental and under development. Please do try it out, but expect breaking changes in the future.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
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
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Excluded from this release type: TypedEventEmitter */
|
|
115
|
+
|
|
116
|
+
export { }
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { AttachState } from '@fluidframework/container-definitions';
|
|
2
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
3
|
+
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
4
|
+
import { IQuorumClients } from '@fluidframework/protocol-definitions';
|
|
5
|
+
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This is to make OldestClientObserver work with either a ContainerRuntime or an IFluidDataStoreRuntime
|
|
9
|
+
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
10
|
+
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
11
|
+
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
16
|
+
getQuorum(): IQuorumClients;
|
|
17
|
+
attachState: AttachState;
|
|
18
|
+
connected: boolean;
|
|
19
|
+
clientId: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Events emitted by {@link IOldestClientObservable}.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare interface IOldestClientObservableEvents extends IEvent {
|
|
28
|
+
(event: "connected", listener: () => void): any;
|
|
29
|
+
(event: "disconnected", listener: () => void): any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
36
|
+
isOldest(): boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Events emitted by {@link IOldestClientObservable}.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare interface IOldestClientObserverEvents extends IEvent {
|
|
45
|
+
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The `OldestClientObserver` is a utility inspect if the local client is the oldest amongst connected clients (in
|
|
50
|
+
* terms of when they connected) and watch for changes.
|
|
51
|
+
*
|
|
52
|
+
* It is still experimental and under development. Please do try it out, but expect breaking changes in the future.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* ### Creation
|
|
56
|
+
*
|
|
57
|
+
* The `OldestClientObserver` constructor takes an `IOldestClientObservable`. This is most easily satisfied with
|
|
58
|
+
* either an `IContainerRuntime` or an `IFluidDataStoreRuntime`:
|
|
59
|
+
*
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // E.g. from within a BaseContainerRuntimeFactory:
|
|
62
|
+
* protected async containerHasInitialized(runtime: IContainerRuntime) {
|
|
63
|
+
* const oldestClientObserver = new OldestClientObserver(runtime);
|
|
64
|
+
* // ...
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* ```typescript
|
|
69
|
+
* // From within a DataObject
|
|
70
|
+
* protected async hasInitialized() {
|
|
71
|
+
* const oldestClientObserver = new OldestClientObserver(this.runtime);
|
|
72
|
+
* // ...
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* ### Usage
|
|
77
|
+
*
|
|
78
|
+
* To check if the local client is the oldest, use the `isOldest()` method.
|
|
79
|
+
*
|
|
80
|
+
* ```typescript
|
|
81
|
+
* if (oldestClientObserver.isOldest()) {
|
|
82
|
+
* console.log("I'm the oldest");
|
|
83
|
+
* } else {
|
|
84
|
+
* console.log("Someone else is older");
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* ### Eventing
|
|
89
|
+
*
|
|
90
|
+
* `OldestClientObserver` is an `EventEmitter`, and will emit events when the local client becomes the oldest and when
|
|
91
|
+
* it is no longer the oldest.
|
|
92
|
+
*
|
|
93
|
+
* ```typescript
|
|
94
|
+
* oldestClientObserver.on("becameOldest", () => {
|
|
95
|
+
* console.log("I'm the oldest now");
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* oldestClientObserver.on("lostOldest", () => {
|
|
99
|
+
* console.log("I'm not the oldest anymore");
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
106
|
+
private readonly observable;
|
|
107
|
+
private readonly quorum;
|
|
108
|
+
private currentIsOldest;
|
|
109
|
+
constructor(observable: IOldestClientObservable);
|
|
110
|
+
isOldest(): boolean;
|
|
111
|
+
private readonly updateOldest;
|
|
112
|
+
private computeIsOldest;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { }
|
|
@@ -58,6 +58,8 @@ import { IOldestClientObservable, IOldestClientObserverEvents, IOldestClientObse
|
|
|
58
58
|
* console.log("I'm not the oldest anymore");
|
|
59
59
|
* });
|
|
60
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
61
63
|
*/
|
|
62
64
|
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
63
65
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;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"}
|
|
@@ -62,6 +62,8 @@ 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
67
|
*/
|
|
66
68
|
class OldestClientObserver extends client_utils_1.TypedEventEmitter {
|
|
67
69
|
constructor(observable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.js","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,2DAAoD;AACpD,iFAAoE;AAQpE
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.js","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,2DAAoD;AACpD,iFAAoE;AAQpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;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 *\n * @public\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/dist/tsdoc-metadata.json
CHANGED
package/lib/interfaces.d.ts
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
import { IEvent, IEventProvider } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
7
7
|
import { IQuorumClients } from "@fluidframework/protocol-definitions";
|
|
8
|
+
/**
|
|
9
|
+
* Events emitted by {@link IOldestClientObservable}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
8
13
|
export interface IOldestClientObservableEvents extends IEvent {
|
|
9
14
|
(event: "connected", listener: () => void): any;
|
|
10
15
|
(event: "disconnected", listener: () => void): any;
|
|
@@ -14,6 +19,8 @@ export interface IOldestClientObservableEvents extends IEvent {
|
|
|
14
19
|
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
15
20
|
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
16
21
|
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
17
24
|
*/
|
|
18
25
|
export interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
19
26
|
getQuorum(): IQuorumClients;
|
|
@@ -21,9 +28,17 @@ export interface IOldestClientObservable extends IEventProvider<IOldestClientObs
|
|
|
21
28
|
connected: boolean;
|
|
22
29
|
clientId: string | undefined;
|
|
23
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Events emitted by {@link IOldestClientObservable}.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
24
36
|
export interface IOldestClientObserverEvents extends IEvent {
|
|
25
37
|
(event: "becameOldest" | "lostOldest", listener: () => void): any;
|
|
26
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
27
42
|
export interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
28
43
|
isOldest(): boolean;
|
|
29
44
|
}
|
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,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
|
|
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;;;;GAIG;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;;;;;;;GAOG;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;;;;GAIG;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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","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\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 */\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\nexport interface IOldestClientObserverEvents extends IEvent {\n\t(event: \"becameOldest\" | \"lostOldest\", listener: () => void);\n}\n\nexport interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {\n\tisOldest(): boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","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 *\n * @public\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 *\n * @public\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 *\n * @public\n */\nexport interface IOldestClientObserverEvents extends IEvent {\n\t(event: \"becameOldest\" | \"lostOldest\", listener: () => void);\n}\n\n/**\n * @public\n */\nexport interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {\n\tisOldest(): boolean;\n}\n"]}
|
|
@@ -58,6 +58,8 @@ import { IOldestClientObservable, IOldestClientObserverEvents, IOldestClientObse
|
|
|
58
58
|
* console.log("I'm not the oldest anymore");
|
|
59
59
|
* });
|
|
60
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
61
63
|
*/
|
|
62
64
|
export declare class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents> implements IOldestClientObserver {
|
|
63
65
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.js","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAQpE
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.js","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAQpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;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 *\n * @public\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-internal.7.
|
|
3
|
+
"version": "2.0.0-internal.7.1.1",
|
|
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": {
|
|
@@ -35,25 +35,25 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluid-internal/client-utils": ">=2.0.0-internal.7.
|
|
39
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.7.
|
|
40
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.
|
|
41
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.7.
|
|
38
|
+
"@fluid-internal/client-utils": ">=2.0.0-internal.7.1.1 <2.0.0-internal.7.2.0",
|
|
39
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.7.1.1 <2.0.0-internal.7.2.0",
|
|
40
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.1.1 <2.0.0-internal.7.2.0",
|
|
41
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.7.1.1 <2.0.0-internal.7.2.0",
|
|
42
42
|
"@fluidframework/protocol-definitions": "^3.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@fluid-internal/test-dds-utils": ">=2.0.0-internal.7.
|
|
46
|
-
"@fluid-tools/build-cli": "^0.
|
|
47
|
-
"@fluidframework/build-common": "^2.0.
|
|
48
|
-
"@fluidframework/build-tools": "^0.
|
|
49
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
50
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.
|
|
45
|
+
"@fluid-internal/test-dds-utils": ">=2.0.0-internal.7.1.1 <2.0.0-internal.7.2.0",
|
|
46
|
+
"@fluid-tools/build-cli": "^0.25.0",
|
|
47
|
+
"@fluidframework/build-common": "^2.0.1",
|
|
48
|
+
"@fluidframework/build-tools": "^0.25.0",
|
|
49
|
+
"@fluidframework/eslint-config-fluid": "^3.0.0",
|
|
50
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.1.1 <2.0.0-internal.7.2.0",
|
|
51
51
|
"@microsoft/api-extractor": "^7.37.0",
|
|
52
52
|
"@types/node": "^16.18.38",
|
|
53
53
|
"copyfiles": "^2.4.1",
|
|
54
54
|
"cross-env": "^7.0.3",
|
|
55
|
-
"eslint": "~8.
|
|
56
|
-
"prettier": "~
|
|
55
|
+
"eslint": "~8.50.0",
|
|
56
|
+
"prettier": "~3.0.3",
|
|
57
57
|
"rimraf": "^4.4.0",
|
|
58
58
|
"typescript": "~5.1.6"
|
|
59
59
|
},
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"build": "fluid-build . --task build",
|
|
74
74
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
75
75
|
"build:compile": "fluid-build . --task compile",
|
|
76
|
-
"build:docs": "api-extractor run --local
|
|
76
|
+
"build:docs": "api-extractor run --local",
|
|
77
77
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
78
|
-
"ci:build:docs": "api-extractor run
|
|
78
|
+
"ci:build:docs": "api-extractor run",
|
|
79
79
|
"clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' '_api-extractor-temp'",
|
|
80
80
|
"eslint": "eslint --format stylish src",
|
|
81
81
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
package/src/interfaces.ts
CHANGED
|
@@ -7,6 +7,11 @@ import { IEvent, IEventProvider } from "@fluidframework/core-interfaces";
|
|
|
7
7
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
8
8
|
import { IQuorumClients } from "@fluidframework/protocol-definitions";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Events emitted by {@link IOldestClientObservable}.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
10
15
|
export interface IOldestClientObservableEvents extends IEvent {
|
|
11
16
|
(event: "connected", listener: () => void);
|
|
12
17
|
(event: "disconnected", listener: () => void);
|
|
@@ -17,6 +22,8 @@ export interface IOldestClientObservableEvents extends IEvent {
|
|
|
17
22
|
* (both expose the relevant API surface and eventing). However, really this info probably shouldn't live on either,
|
|
18
23
|
* since neither is really the source of truth (they are just the only currently-available plumbing options).
|
|
19
24
|
* It's information about the connection, so the real source of truth is lower (at the connection layer).
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
20
27
|
*/
|
|
21
28
|
export interface IOldestClientObservable extends IEventProvider<IOldestClientObservableEvents> {
|
|
22
29
|
getQuorum(): IQuorumClients;
|
|
@@ -30,10 +37,18 @@ export interface IOldestClientObservable extends IEventProvider<IOldestClientObs
|
|
|
30
37
|
clientId: string | undefined;
|
|
31
38
|
}
|
|
32
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Events emitted by {@link IOldestClientObservable}.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
33
45
|
export interface IOldestClientObserverEvents extends IEvent {
|
|
34
46
|
(event: "becameOldest" | "lostOldest", listener: () => void);
|
|
35
47
|
}
|
|
36
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
37
52
|
export interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {
|
|
38
53
|
isOldest(): boolean;
|
|
39
54
|
}
|