@fluid-experimental/oldest-client-observer 2.0.0-internal.7.1.0 → 2.0.0-internal.7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
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.2.0",
|
|
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,22 +35,21 @@
|
|
|
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.2.0 <2.0.0-internal.7.3.0",
|
|
39
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
40
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
41
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.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.
|
|
45
|
+
"@fluid-internal/test-dds-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
46
|
+
"@fluid-tools/build-cli": "^0.26.1",
|
|
47
|
+
"@fluidframework/build-common": "^2.0.3",
|
|
48
|
+
"@fluidframework/build-tools": "^0.26.1",
|
|
49
49
|
"@fluidframework/eslint-config-fluid": "^3.0.0",
|
|
50
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.
|
|
50
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
51
51
|
"@microsoft/api-extractor": "^7.37.0",
|
|
52
52
|
"@types/node": "^16.18.38",
|
|
53
|
-
"copyfiles": "^2.4.1",
|
|
54
53
|
"cross-env": "^7.0.3",
|
|
55
54
|
"eslint": "~8.50.0",
|
|
56
55
|
"prettier": "~3.0.3",
|
|
@@ -76,7 +75,7 @@
|
|
|
76
75
|
"build:docs": "api-extractor run --local",
|
|
77
76
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
78
77
|
"ci:build:docs": "api-extractor run",
|
|
79
|
-
"clean": "rimraf --glob
|
|
78
|
+
"clean": "rimraf --glob dist lib \"*.tsbuildinfo\" \"*.build.log\" _api-extractor-temp",
|
|
80
79
|
"eslint": "eslint --format stylish src",
|
|
81
80
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
82
81
|
"format": "npm run prettier:fix",
|
|
@@ -1,116 +0,0 @@
|
|
|
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 { }
|
|
@@ -1,116 +0,0 @@
|
|
|
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 { }
|
|
@@ -1,116 +0,0 @@
|
|
|
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 { }
|
|
@@ -1,115 +0,0 @@
|
|
|
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 { }
|