@fluid-experimental/oldest-client-observer 2.0.0-internal.2.2.0 → 2.0.0-internal.2.3.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/README.md +8 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/oldestClientObserver.d.ts.map +1 -1
- package/dist/oldestClientObserver.js +2 -0
- package/dist/oldestClientObserver.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/oldestClientObserver.d.ts.map +1 -1
- package/lib/oldestClientObserver.js +2 -0
- package/lib/oldestClientObserver.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +6 -6
- package/src/interfaces.ts +0 -3
- package/src/oldestClientObserver.ts +3 -1
- package/src/packageVersion.ts +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# @fluid-experimental/oldest-client-observer
|
|
2
2
|
|
|
3
3
|
<!-- AUTO-GENERATED-CONTENT:START (README_TRADEMARK_SECTION:includeHeading=TRUE) -->
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore-start -->
|
|
6
|
+
|
|
7
|
+
<!-- This section is automatically generated. To update it, make the appropriate changes to docs/md-magic.config.js or the embedded content, then run 'npm run build:md-magic' in the docs folder. -->
|
|
8
|
+
|
|
4
9
|
## Trademark
|
|
5
10
|
|
|
6
11
|
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
7
12
|
Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
8
13
|
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
14
|
+
|
|
15
|
+
<!-- prettier-ignore-end -->
|
|
16
|
+
|
|
9
17
|
<!-- AUTO-GENERATED-CONTENT:END -->
|
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,oCAAoC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,MAAM,WAAW,6BAA8B,SAAQ,MAAM;IACzD,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,MAAM,WAAW,6BAA8B,SAAQ,MAAM;IACzD,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;IAC3C,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CACjD;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,cAAc,CAAC,6BAA6B,CAAC;IAC1F,SAAS,IAAI,cAAc,CAAC;IAM5B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,2BAA4B,SAAQ,MAAM;IACvD,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CAChE;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,2BAA2B,CAAC;IACtF,QAAQ,IAAI,OAAO,CAAC;CACvB"}
|
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/common-definitions\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\n\nexport interface IOldestClientObservableEvents extends IEvent {\n (event: \"connected\", listener: () => void);\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/common-definitions\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\n\nexport interface IOldestClientObservableEvents extends IEvent {\n (event: \"connected\", listener: () => void);\n (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 getQuorum(): IQuorumClients;\n // Generic usage of attachState is a little unusual here. We will treat ourselves as \"the oldest client that\n // has information about this [container | data store]\", which in the case of detached data store may disagree\n // with whether we're the oldest client on the connected container. So in the data store case, it's only\n // safe use this as an indicator about rights to tasks performed against this specific data store, and not\n // more broadly.\n attachState: AttachState;\n connected: boolean;\n clientId: string | undefined;\n}\n\nexport interface IOldestClientObserverEvents extends IEvent {\n (event: \"becameOldest\" | \"lostOldest\", listener: () => void);\n}\n\nexport interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {\n isOldest(): boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.d.ts","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB,CAAC,2BAA2B,CACnF,YAAW,qBAAqB;IAGpB,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;
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.d.ts","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB,CAAC,2BAA2B,CACnF,YAAW,qBAAqB;IAGpB,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;CA+B1B"}
|
|
@@ -98,6 +98,8 @@ class OldestClientObserver extends common_utils_1.TypedEventEmitter {
|
|
|
98
98
|
if (!this.observable.connected) {
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
|
+
// TODO: Clean up error code linter violations repo-wide.
|
|
102
|
+
// eslint-disable-next-line unicorn/numeric-separators-style
|
|
101
103
|
(0, common_utils_1.assert)(this.observable.clientId !== undefined, 0x1da /* "Client id should be set if connected" */);
|
|
102
104
|
const selfSequencedClient = this.quorum.getMember(this.observable.clientId);
|
|
103
105
|
// When in readonly mode our clientId will not be present in the quorum.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.js","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AACzE,iFAAoE;AAIpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAa,oBAAqB,SAAQ,gCAA8C;IAIpF,YAA6B,UAAmC;QAC5D,KAAK,EAAE,CAAC;QADiB,eAAU,GAAV,UAAU,CAAyB;QADxD,oBAAe,GAAY,KAAK,CAAC;QAexB,iBAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.js","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AACzE,iFAAoE;AAIpE;;;;;;;;;;;;;;;;;;;;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AC,UAAU,CAAC,SAAS,EAAE;YAC5B,OAAO,KAAK,CAAC;SAChB;QAED,yDAAyD;QACzD,4DAA4D;QAC5D,IAAA,qBAAM,EAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAEnG,MAAM,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5E,wEAAwE;QACxE,IAAI,mBAAmB,KAAK,SAAS,EAAE;YACnC,OAAO,KAAK,CAAC;SAChB;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACzC,KAAK,MAAM,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE;YAC5C,IAAI,eAAe,CAAC,cAAc,GAAG,mBAAmB,CAAC,cAAc,EAAE;gBACrE,OAAO,KAAK,CAAC;aAChB;SACJ;QAED,oCAAoC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA7DD,oDA6DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport { IOldestClientObservable, IOldestClientObserverEvents, IOldestClientObserver } 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 */\nexport class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents>\n implements IOldestClientObserver {\n private readonly quorum: IQuorumClients;\n private currentIsOldest: boolean = false;\n constructor(private readonly observable: IOldestClientObservable) {\n super();\n this.quorum = this.observable.getQuorum();\n this.currentIsOldest = this.computeIsOldest();\n this.quorum.on(\"addMember\", this.updateOldest);\n this.quorum.on(\"removeMember\", this.updateOldest);\n observable.on(\"connected\", this.updateOldest);\n observable.on(\"disconnected\", this.updateOldest);\n }\n\n public isOldest(): boolean {\n return this.currentIsOldest;\n }\n\n private readonly updateOldest = (): void => {\n const oldest = this.computeIsOldest();\n if (this.currentIsOldest !== oldest) {\n this.currentIsOldest = oldest;\n if (oldest) {\n this.emit(\"becameOldest\");\n } else {\n this.emit(\"lostOldest\");\n }\n }\n };\n\n private computeIsOldest(): boolean {\n // If the container is detached, we are the only ones that know about it and are the oldest by default.\n if (this.observable.attachState === AttachState.Detached) {\n return true;\n }\n\n // If we're not connected we can't be the oldest connected client.\n if (!this.observable.connected) {\n return false;\n }\n\n // TODO: Clean up error code linter violations repo-wide.\n // eslint-disable-next-line unicorn/numeric-separators-style\n assert(this.observable.clientId !== undefined, 0x1da /* \"Client id should be set if connected\" */);\n\n const selfSequencedClient = this.quorum.getMember(this.observable.clientId);\n // When in readonly mode our clientId will not be present in the quorum.\n if (selfSequencedClient === undefined) {\n return false;\n }\n\n const members = this.quorum.getMembers();\n for (const sequencedClient of members.values()) {\n if (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n return false;\n }\n }\n\n // No member of the quorum was older\n return true;\n }\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluid-experimental/oldest-client-observer";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.2.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.2.3.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluid-experimental/oldest-client-observer";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.2.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.2.3.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,4CAA4C,CAAC;AACvD,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/oldest-client-observer\";\nexport const pkgVersion = \"2.0.0-internal.2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,4CAA4C,CAAC;AACvD,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/oldest-client-observer\";\nexport const pkgVersion = \"2.0.0-internal.2.3.0\";\n"]}
|
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,oCAAoC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,MAAM,WAAW,6BAA8B,SAAQ,MAAM;IACzD,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,MAAM,WAAW,6BAA8B,SAAQ,MAAM;IACzD,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;IAC3C,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CACjD;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,cAAc,CAAC,6BAA6B,CAAC;IAC1F,SAAS,IAAI,cAAc,CAAC;IAM5B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,2BAA4B,SAAQ,MAAM;IACvD,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CAChE;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,2BAA2B,CAAC;IACtF,QAAQ,IAAI,OAAO,CAAC;CACvB"}
|
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/common-definitions\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\n\nexport interface IOldestClientObservableEvents extends IEvent {\n (event: \"connected\", listener: () => void);\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/common-definitions\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\n\nexport interface IOldestClientObservableEvents extends IEvent {\n (event: \"connected\", listener: () => void);\n (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 getQuorum(): IQuorumClients;\n // Generic usage of attachState is a little unusual here. We will treat ourselves as \"the oldest client that\n // has information about this [container | data store]\", which in the case of detached data store may disagree\n // with whether we're the oldest client on the connected container. So in the data store case, it's only\n // safe use this as an indicator about rights to tasks performed against this specific data store, and not\n // more broadly.\n attachState: AttachState;\n connected: boolean;\n clientId: string | undefined;\n}\n\nexport interface IOldestClientObserverEvents extends IEvent {\n (event: \"becameOldest\" | \"lostOldest\", listener: () => void);\n}\n\nexport interface IOldestClientObserver extends IEventProvider<IOldestClientObserverEvents> {\n isOldest(): boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.d.ts","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB,CAAC,2BAA2B,CACnF,YAAW,qBAAqB;IAGpB,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;
|
|
1
|
+
{"version":3,"file":"oldestClientObserver.d.ts","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB,CAAC,2BAA2B,CACnF,YAAW,qBAAqB;IAGpB,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;CA+B1B"}
|
|
@@ -95,6 +95,8 @@ export class OldestClientObserver extends TypedEventEmitter {
|
|
|
95
95
|
if (!this.observable.connected) {
|
|
96
96
|
return false;
|
|
97
97
|
}
|
|
98
|
+
// TODO: Clean up error code linter violations repo-wide.
|
|
99
|
+
// eslint-disable-next-line unicorn/numeric-separators-style
|
|
98
100
|
assert(this.observable.clientId !== undefined, 0x1da /* "Client id should be set if connected" */);
|
|
99
101
|
const selfSequencedClient = this.quorum.getMember(this.observable.clientId);
|
|
100
102
|
// When in readonly mode our clientId will not be present in the quorum.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oldestClientObserver.js","sourceRoot":"","sources":["../src/oldestClientObserver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CA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n */\n\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport { IOldestClientObservable, IOldestClientObserverEvents, IOldestClientObserver } 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 */\nexport class OldestClientObserver extends TypedEventEmitter<IOldestClientObserverEvents>\n implements IOldestClientObserver {\n private readonly quorum: IQuorumClients;\n private currentIsOldest: boolean = false;\n constructor(private readonly observable: IOldestClientObservable) {\n super();\n this.quorum = this.observable.getQuorum();\n this.currentIsOldest = this.computeIsOldest();\n this.quorum.on(\"addMember\", this.updateOldest);\n this.quorum.on(\"removeMember\", this.updateOldest);\n observable.on(\"connected\", this.updateOldest);\n observable.on(\"disconnected\", this.updateOldest);\n }\n\n public isOldest(): boolean {\n return this.currentIsOldest;\n }\n\n private readonly updateOldest = (): void => {\n const oldest = this.computeIsOldest();\n if (this.currentIsOldest !== oldest) {\n this.currentIsOldest = oldest;\n if (oldest) {\n this.emit(\"becameOldest\");\n } else {\n this.emit(\"lostOldest\");\n }\n }\n };\n\n private computeIsOldest(): boolean {\n // If the container is detached, we are the only ones that know about it and are the oldest by default.\n if (this.observable.attachState === AttachState.Detached) {\n return true;\n }\n\n // If we're not connected we can't be the oldest connected client.\n if (!this.observable.connected) {\n return false;\n }\n\n // TODO: Clean up error code linter violations repo-wide.\n // eslint-disable-next-line unicorn/numeric-separators-style\n assert(this.observable.clientId !== undefined, 0x1da /* \"Client id should be set if connected\" */);\n\n const selfSequencedClient = this.quorum.getMember(this.observable.clientId);\n // When in readonly mode our clientId will not be present in the quorum.\n if (selfSequencedClient === undefined) {\n return false;\n }\n\n const members = this.quorum.getMembers();\n for (const sequencedClient of members.values()) {\n if (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n return false;\n }\n }\n\n // No member of the quorum was older\n return true;\n }\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluid-experimental/oldest-client-observer";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.2.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.2.3.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluid-experimental/oldest-client-observer";
|
|
8
|
-
export const pkgVersion = "2.0.0-internal.2.
|
|
8
|
+
export const pkgVersion = "2.0.0-internal.2.3.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,4CAA4C,CAAC;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/oldest-client-observer\";\nexport const pkgVersion = \"2.0.0-internal.2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,4CAA4C,CAAC;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/oldest-client-observer\";\nexport const pkgVersion = \"2.0.0-internal.2.3.0\";\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.2.
|
|
3
|
+
"version": "2.0.0-internal.2.3.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": {
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
61
61
|
"@fluidframework/common-utils": "^1.0.0",
|
|
62
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.2.
|
|
62
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.2.3.0 <2.0.0-internal.3.0.0",
|
|
63
63
|
"@fluidframework/protocol-definitions": "^1.1.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@fluid-internal/test-dds-utils": ">=2.0.0-internal.2.
|
|
66
|
+
"@fluid-internal/test-dds-utils": ">=2.0.0-internal.2.3.0 <2.0.0-internal.3.0.0",
|
|
67
67
|
"@fluid-tools/build-cli": "^0.7.0",
|
|
68
68
|
"@fluidframework/build-common": "^1.1.0",
|
|
69
69
|
"@fluidframework/build-tools": "^0.7.0",
|
|
70
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
71
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.
|
|
72
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.2.
|
|
70
|
+
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
71
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.3.0 <2.0.0-internal.3.0.0",
|
|
72
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.2.3.0 <2.0.0-internal.3.0.0",
|
|
73
73
|
"@microsoft/api-extractor": "^7.22.2",
|
|
74
74
|
"@rushstack/eslint-config": "^2.5.1",
|
|
75
75
|
"@types/mocha": "^9.1.1",
|
package/src/interfaces.ts
CHANGED
|
@@ -9,9 +9,6 @@ import { IQuorumClients } from "@fluidframework/protocol-definitions";
|
|
|
9
9
|
|
|
10
10
|
export interface IOldestClientObservableEvents extends IEvent {
|
|
11
11
|
(event: "connected", listener: () => void);
|
|
12
|
-
// Typescript won't convert IFluidDataStoreRuntime and ContainerRuntime if we unify these,
|
|
13
|
-
// I believe this is because the "connected" event has a clientId arg in the runtimes.
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
|
15
12
|
(event: "disconnected", listener: () => void);
|
|
16
13
|
}
|
|
17
14
|
|
|
@@ -81,7 +81,7 @@ export class OldestClientObserver extends TypedEventEmitter<IOldestClientObserve
|
|
|
81
81
|
return this.currentIsOldest;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
private readonly updateOldest = () => {
|
|
84
|
+
private readonly updateOldest = (): void => {
|
|
85
85
|
const oldest = this.computeIsOldest();
|
|
86
86
|
if (this.currentIsOldest !== oldest) {
|
|
87
87
|
this.currentIsOldest = oldest;
|
|
@@ -104,6 +104,8 @@ export class OldestClientObserver extends TypedEventEmitter<IOldestClientObserve
|
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
// TODO: Clean up error code linter violations repo-wide.
|
|
108
|
+
// eslint-disable-next-line unicorn/numeric-separators-style
|
|
107
109
|
assert(this.observable.clientId !== undefined, 0x1da /* "Client id should be set if connected" */);
|
|
108
110
|
|
|
109
111
|
const selfSequencedClient = this.quorum.getMember(this.observable.clientId);
|
package/src/packageVersion.ts
CHANGED