@rushstack/rush-redis-cobuild-plugin 5.110.0 → 5.110.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/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- @rushstack/rush-redis-cobuild-plugin
2
-
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
-
5
- MIT License
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining
8
- a copy of this software and associated documentation files (the
9
- "Software"), to deal in the Software without restriction, including
10
- without limitation the rights to use, copy, modify, merge, publish,
11
- distribute, sublicense, and/or sell copies of the Software, and to
12
- permit persons to whom the Software is furnished to do so, subject to
13
- the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ @rushstack/rush-redis-cobuild-plugin
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # @rushstack/rush-redis-cobuild-plugin
2
-
3
- This is a Rush plugin for using Redis as cobuild lock provider during the "build"
4
-
5
- ## Links
6
-
7
- - [CHANGELOG.md](
8
- https://github.com/microsoft/rushstack/blob/main/rush-plugins/rush-redis-cobuild-plugin/CHANGELOG.md) - Find
9
- out what's new in the latest version
1
+ # @rushstack/rush-redis-cobuild-plugin
2
+
3
+ This is a Rush plugin for using Redis as cobuild lock provider during the "build"
4
+
5
+ ## Links
6
+
7
+ - [CHANGELOG.md](
8
+ https://github.com/microsoft/rushstack/blob/main/rush-plugins/rush-redis-cobuild-plugin/CHANGELOG.md) - Find
9
+ out what's new in the latest version
@@ -1 +1 @@
1
- {"version":3,"file":"RedisCobuildLockProvider.js","sourceRoot":"","sources":["../src/RedisCobuildLockProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,0CAA6C;AA4B7C,MAAM,yBAAyB,GAAQ,GAAG,CAAC;AAE3C;;GAEG;AACH,MAAa,wBAAwB;IAcnC,YAAmB,OAAyC,EAAE,WAAwB;QAXrE,0BAAqB,GAAqC,IAAI,OAAO,EAGnF,CAAC;QACa,oCAA+B,GAAqC,IAAI,OAAO,EAG7F,CAAC;QAKF,IAAI,C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G,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACjE,OAAO,EAAE,MAAM,EAAE,MAA0C,EAAE,OAAO,EAAE,CAAC;IACzE,CAAC;IAEO,qBAAqB,CAAC,OAAwB;QACpD,IAAI,iBAAiB,GAAuB,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpF,IAAI,iBAAiB,KAAK,SAAS,EAAE;YACnC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;YACpD,iBAAiB,GAAG,QAAQ,OAAO,aAAa,WAAW,WAAW,SAAS,GAAG,CAAC;YACnF,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;SAC5D;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,+BAA+B,CAAC,OAAwB;QAC9D,IAAI,2BAA2B,GAAuB,IAAI,CAAC,+BAA+B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxG,IAAI,2BAA2B,KAAK,SAAS,EAAE;YAC7C,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;YAC9D,2BAA2B,GAAG,mBAAmB,iBAAiB,aAAa,WAAW,WAAW,SAAS,GAAG,CAAC;YAClH,IAAI,CAAC,+BAA+B,CAAC,GAAG,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAC;SAChF;QACD,OAAO,2BAA2B,CAAC;IACrC,CAAC;CACF;AAzLD,4DAyLC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { createClient } from '@redis/client';\r\n\r\nimport type {\r\n ICobuildLockProvider,\r\n ICobuildContext,\r\n ICobuildCompletedState,\r\n RushSession\r\n} from '@rushstack/rush-sdk';\r\nimport type {\r\n RedisClientOptions,\r\n RedisClientType,\r\n RedisFunctions,\r\n RedisModules,\r\n RedisScripts\r\n} from '@redis/client';\r\nimport type { ITerminal } from '@rushstack/node-core-library';\r\n\r\n/**\r\n * The redis client options\r\n * @beta\r\n */\r\nexport interface IRedisCobuildLockProviderOptions extends RedisClientOptions {\r\n /**\r\n * The environment variable name for the redis password\r\n */\r\n passwordEnvironmentVariable?: string;\r\n}\r\n\r\nconst COMPLETED_STATE_SEPARATOR: ';' = ';';\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class RedisCobuildLockProvider implements ICobuildLockProvider {\r\n private readonly _options: IRedisCobuildLockProviderOptions;\r\n private readonly _terminal: ITerminal;\r\n private readonly _lockKeyIdentifierMap: WeakMap<ICobuildContext, string> = new WeakMap<\r\n ICobuildContext,\r\n string\r\n >();\r\n private readonly _completedStateKeyIdentifierMap: WeakMap<ICobuildContext, string> = new WeakMap<\r\n ICobuildContext,\r\n string\r\n >();\r\n\r\n private readonly _redisClient: RedisClientType<RedisModules, RedisFunctions, RedisScripts>;\r\n\r\n public constructor(options: IRedisCobuildLockProviderOptions, rushSession: RushSession) {\r\n this._options = RedisCobuildLockProvider.expandOptionsWithEnvironmentVariables(options);\r\n this._terminal = rushSession.getLogger('RedisCobuildLockProvider').terminal;\r\n try {\r\n this._redisClient = createClient(this._options);\r\n } catch (e) {\r\n throw new Error(`Failed to create redis client: ${e.message}`);\r\n }\r\n }\r\n\r\n public static expandOptionsWithEnvironmentVariables(\r\n options: IRedisCobuildLockProviderOptions,\r\n environment: NodeJS.ProcessEnv = process.env\r\n ): IRedisCobuildLockProviderOptions {\r\n const finalOptions: IRedisCobuildLockProviderOptions = { ...options };\r\n const missingEnvironmentVariables: Set<string> = new Set<string>();\r\n\r\n if (finalOptions.passwordEnvironmentVariable) {\r\n const password: string | undefined = environment[finalOptions.passwordEnvironmentVariable];\r\n if (password !== undefined) {\r\n finalOptions.password = password;\r\n } else {\r\n missingEnvironmentVariables.add(finalOptions.passwordEnvironmentVariable);\r\n }\r\n finalOptions.passwordEnvironmentVariable = undefined;\r\n }\r\n\r\n if (missingEnvironmentVariables.size) {\r\n throw new Error(\r\n `The \"RedisCobuildLockProvider\" tries to access missing environment variable${\r\n missingEnvironmentVariables.size > 1 ? 's' : ''\r\n }: ${Array.from(missingEnvironmentVariables).join(\r\n ', '\r\n )}\\nPlease check the configuration in rush-redis-cobuild-plugin.json file`\r\n );\r\n }\r\n return finalOptions;\r\n }\r\n\r\n public async connectAsync(): Promise<void> {\r\n try {\r\n await this._redisClient.connect();\r\n // Check the connection works at early stage\r\n await this._redisClient.ping();\r\n } catch (e) {\r\n throw new Error(`Failed to connect to redis server: ${e.message}`);\r\n }\r\n }\r\n\r\n public async disconnectAsync(): Promise<void> {\r\n try {\r\n await this._redisClient.disconnect();\r\n } catch (e) {\r\n throw new Error(`Failed to disconnect to redis server: ${e.message}`);\r\n }\r\n }\r\n\r\n /**\r\n * Acquiring the lock based on the specific context.\r\n *\r\n * NOTE: this is a reentrant lock implementation\r\n */\r\n public async acquireLockAsync(context: ICobuildContext): Promise<boolean> {\r\n const { _terminal: terminal } = this;\r\n const { lockKey, lockExpireTimeInSeconds, runnerId } = context;\r\n let result: boolean = false;\r\n const lockKeyIdentifier: string = this._getLockKeyIdentifier(context);\r\n try {\r\n // According to the doc, the reply of set command is either \"OK\" or nil. The reply doesn't matter\r\n await this._redisClient.set(lockKey, runnerId, {\r\n NX: true,\r\n // call EXPIRE in an atomic command\r\n EX: lockExpireTimeInSeconds\r\n // Do not specify GET here since using NX ane GET together requires Redis@7.\r\n });\r\n // Just read the value by lock key to see wether it equals current runner id\r\n const value: string | null = await this._redisClient.get(lockKey);\r\n if (value === null) {\r\n // This should not happen.\r\n throw new Error(`Get redis key failed: ${lockKey}`);\r\n }\r\n result = value === runnerId;\r\n if (result) {\r\n terminal.writeDebugLine(\r\n `Successfully acquired ${lockKeyIdentifier} to runner(${runnerId}) and it expires in ${lockExpireTimeInSeconds}s`\r\n );\r\n } else {\r\n terminal.writeDebugLine(`Failed to acquire ${lockKeyIdentifier}, locked by runner ${value}`);\r\n }\r\n } catch (e) {\r\n throw new Error(`Error occurs when acquiring ${lockKeyIdentifier}: ${e.message}`);\r\n }\r\n return result;\r\n }\r\n\r\n public async renewLockAsync(context: ICobuildContext): Promise<void> {\r\n const { _terminal: terminal } = this;\r\n const { lockKey, lockExpireTimeInSeconds } = context;\r\n const lockKeyIdentifier: string = this._getLockKeyIdentifier(context);\r\n try {\r\n await this._redisClient.expire(lockKey, lockExpireTimeInSeconds);\r\n } catch (e) {\r\n throw new Error(`Failed to renew ${lockKeyIdentifier}: ${e.message}`);\r\n }\r\n terminal.writeDebugLine(`Renewed ${lockKeyIdentifier} expires in ${lockExpireTimeInSeconds} seconds`);\r\n }\r\n\r\n public async setCompletedStateAsync(\r\n context: ICobuildContext,\r\n state: ICobuildCompletedState\r\n ): Promise<void> {\r\n const { _terminal: terminal } = this;\r\n const { completedStateKey: key } = context;\r\n const value: string = this._serializeCompletedState(state);\r\n const completedStateKeyIdentifier: string = this._getCompletedStateKeyIdentifier(context);\r\n try {\r\n await this._redisClient.set(key, value);\r\n } catch (e) {\r\n throw new Error(`Failed to set ${completedStateKeyIdentifier}: ${e.message}`);\r\n }\r\n terminal.writeDebugLine(`Set ${completedStateKeyIdentifier}: ${value}`);\r\n }\r\n\r\n public async getCompletedStateAsync(context: ICobuildContext): Promise<ICobuildCompletedState | undefined> {\r\n const { _terminal: terminal } = this;\r\n const { completedStateKey: key } = context;\r\n const completedStateKeyIdentifier: string = this._getCompletedStateKeyIdentifier(context);\r\n let state: ICobuildCompletedState | undefined;\r\n try {\r\n const value: string | null = await this._redisClient.get(key);\r\n if (value) {\r\n state = this._deserializeCompletedState(value);\r\n }\r\n terminal.writeDebugLine(`Get ${completedStateKeyIdentifier}: ${value}`);\r\n } catch (e) {\r\n throw new Error(`Failed to get ${completedStateKeyIdentifier}: ${e.message}`);\r\n }\r\n return state;\r\n }\r\n\r\n private _serializeCompletedState(state: ICobuildCompletedState): string {\r\n // Example: SUCCESS;1234567890\r\n // Example: FAILURE;1234567890\r\n const { status, cacheId } = state;\r\n return [status, cacheId].join(COMPLETED_STATE_SEPARATOR);\r\n }\r\n\r\n private _deserializeCompletedState(state: string): ICobuildCompletedState | undefined {\r\n const [status, cacheId] = state.split(COMPLETED_STATE_SEPARATOR);\r\n return { status: status as ICobuildCompletedState['status'], cacheId };\r\n }\r\n\r\n private _getLockKeyIdentifier(context: ICobuildContext): string {\r\n let lockKeyIdentifier: string | undefined = this._lockKeyIdentifierMap.get(context);\r\n if (lockKeyIdentifier === undefined) {\r\n const { lockKey, packageName, phaseName } = context;\r\n lockKeyIdentifier = `lock(${lockKey})_package(${packageName})_phase(${phaseName})`;\r\n this._lockKeyIdentifierMap.set(context, lockKeyIdentifier);\r\n }\r\n return lockKeyIdentifier;\r\n }\r\n\r\n private _getCompletedStateKeyIdentifier(context: ICobuildContext): string {\r\n let completedStateKeyIdentifier: string | undefined = this._completedStateKeyIdentifierMap.get(context);\r\n if (completedStateKeyIdentifier === undefined) {\r\n const { completedStateKey, packageName, phaseName } = context;\r\n completedStateKeyIdentifier = `completed_state(${completedStateKey})_package(${packageName})_phase(${phaseName})`;\r\n this._completedStateKeyIdentifierMap.set(context, completedStateKeyIdentifier);\r\n }\r\n return completedStateKeyIdentifier;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RedisCobuildLockProvider.js","sourceRoot":"","sources":["../src/RedisCobuildLockProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,0CAA6C;AA4B7C,MAAM,yBAAyB,GAAQ,GAAG,CAAC;AAE3C;;GAEG;AACH,MAAa,wBAAwB;IAcnC,YAAmB,OAAyC,EAAE,WAAwB;QAXrE,0BAAqB,GAAqC,IAAI,OAAO,EAGnF,CAAC;QACa,oCAA+B,GAAqC,IAAI,OAAO,EAG7F,CAAC;QAKF,IAAI,CAAC,QAAQ,GAAG,wBAAwB,CAAC,qCAAqC,CAAC,OAAO,CAAC,CAAC;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MAAM,EAAE,MAA0C,EAAE,OAAO,EAAE,CAAC;IACzE,CAAC;IAEO,qBAAqB,CAAC,OAAwB;QACpD,IAAI,iBAAiB,GAAuB,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpF,IAAI,iBAAiB,KAAK,SAAS,EAAE;YACnC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;YACpD,iBAAiB,GAAG,QAAQ,OAAO,aAAa,WAAW,WAAW,SAAS,GAAG,CAAC;YACnF,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;SAC5D;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,+BAA+B,CAAC,OAAwB;QAC9D,IAAI,2BAA2B,GAAuB,IAAI,CAAC,+BAA+B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxG,IAAI,2BAA2B,KAAK,SAAS,EAAE;YAC7C,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;YAC9D,2BAA2B,GAAG,mBAAmB,iBAAiB,aAAa,WAAW,WAAW,SAAS,GAAG,CAAC;YAClH,IAAI,CAAC,+BAA+B,CAAC,GAAG,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAC;SAChF;QACD,OAAO,2BAA2B,CAAC;IACrC,CAAC;CACF;AAzLD,4DAyLC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { createClient } from '@redis/client';\n\nimport type {\n ICobuildLockProvider,\n ICobuildContext,\n ICobuildCompletedState,\n RushSession\n} from '@rushstack/rush-sdk';\nimport type {\n RedisClientOptions,\n RedisClientType,\n RedisFunctions,\n RedisModules,\n RedisScripts\n} from '@redis/client';\nimport type { ITerminal } from '@rushstack/node-core-library';\n\n/**\n * The redis client options\n * @beta\n */\nexport interface IRedisCobuildLockProviderOptions extends RedisClientOptions {\n /**\n * The environment variable name for the redis password\n */\n passwordEnvironmentVariable?: string;\n}\n\nconst COMPLETED_STATE_SEPARATOR: ';' = ';';\n\n/**\n * @beta\n */\nexport class RedisCobuildLockProvider implements ICobuildLockProvider {\n private readonly _options: IRedisCobuildLockProviderOptions;\n private readonly _terminal: ITerminal;\n private readonly _lockKeyIdentifierMap: WeakMap<ICobuildContext, string> = new WeakMap<\n ICobuildContext,\n string\n >();\n private readonly _completedStateKeyIdentifierMap: WeakMap<ICobuildContext, string> = new WeakMap<\n ICobuildContext,\n string\n >();\n\n private readonly _redisClient: RedisClientType<RedisModules, RedisFunctions, RedisScripts>;\n\n public constructor(options: IRedisCobuildLockProviderOptions, rushSession: RushSession) {\n this._options = RedisCobuildLockProvider.expandOptionsWithEnvironmentVariables(options);\n this._terminal = rushSession.getLogger('RedisCobuildLockProvider').terminal;\n try {\n this._redisClient = createClient(this._options);\n } catch (e) {\n throw new Error(`Failed to create redis client: ${e.message}`);\n }\n }\n\n public static expandOptionsWithEnvironmentVariables(\n options: IRedisCobuildLockProviderOptions,\n environment: NodeJS.ProcessEnv = process.env\n ): IRedisCobuildLockProviderOptions {\n const finalOptions: IRedisCobuildLockProviderOptions = { ...options };\n const missingEnvironmentVariables: Set<string> = new Set<string>();\n\n if (finalOptions.passwordEnvironmentVariable) {\n const password: string | undefined = environment[finalOptions.passwordEnvironmentVariable];\n if (password !== undefined) {\n finalOptions.password = password;\n } else {\n missingEnvironmentVariables.add(finalOptions.passwordEnvironmentVariable);\n }\n finalOptions.passwordEnvironmentVariable = undefined;\n }\n\n if (missingEnvironmentVariables.size) {\n throw new Error(\n `The \"RedisCobuildLockProvider\" tries to access missing environment variable${\n missingEnvironmentVariables.size > 1 ? 's' : ''\n }: ${Array.from(missingEnvironmentVariables).join(\n ', '\n )}\\nPlease check the configuration in rush-redis-cobuild-plugin.json file`\n );\n }\n return finalOptions;\n }\n\n public async connectAsync(): Promise<void> {\n try {\n await this._redisClient.connect();\n // Check the connection works at early stage\n await this._redisClient.ping();\n } catch (e) {\n throw new Error(`Failed to connect to redis server: ${e.message}`);\n }\n }\n\n public async disconnectAsync(): Promise<void> {\n try {\n await this._redisClient.disconnect();\n } catch (e) {\n throw new Error(`Failed to disconnect to redis server: ${e.message}`);\n }\n }\n\n /**\n * Acquiring the lock based on the specific context.\n *\n * NOTE: this is a reentrant lock implementation\n */\n public async acquireLockAsync(context: ICobuildContext): Promise<boolean> {\n const { _terminal: terminal } = this;\n const { lockKey, lockExpireTimeInSeconds, runnerId } = context;\n let result: boolean = false;\n const lockKeyIdentifier: string = this._getLockKeyIdentifier(context);\n try {\n // According to the doc, the reply of set command is either \"OK\" or nil. The reply doesn't matter\n await this._redisClient.set(lockKey, runnerId, {\n NX: true,\n // call EXPIRE in an atomic command\n EX: lockExpireTimeInSeconds\n // Do not specify GET here since using NX ane GET together requires Redis@7.\n });\n // Just read the value by lock key to see wether it equals current runner id\n const value: string | null = await this._redisClient.get(lockKey);\n if (value === null) {\n // This should not happen.\n throw new Error(`Get redis key failed: ${lockKey}`);\n }\n result = value === runnerId;\n if (result) {\n terminal.writeDebugLine(\n `Successfully acquired ${lockKeyIdentifier} to runner(${runnerId}) and it expires in ${lockExpireTimeInSeconds}s`\n );\n } else {\n terminal.writeDebugLine(`Failed to acquire ${lockKeyIdentifier}, locked by runner ${value}`);\n }\n } catch (e) {\n throw new Error(`Error occurs when acquiring ${lockKeyIdentifier}: ${e.message}`);\n }\n return result;\n }\n\n public async renewLockAsync(context: ICobuildContext): Promise<void> {\n const { _terminal: terminal } = this;\n const { lockKey, lockExpireTimeInSeconds } = context;\n const lockKeyIdentifier: string = this._getLockKeyIdentifier(context);\n try {\n await this._redisClient.expire(lockKey, lockExpireTimeInSeconds);\n } catch (e) {\n throw new Error(`Failed to renew ${lockKeyIdentifier}: ${e.message}`);\n }\n terminal.writeDebugLine(`Renewed ${lockKeyIdentifier} expires in ${lockExpireTimeInSeconds} seconds`);\n }\n\n public async setCompletedStateAsync(\n context: ICobuildContext,\n state: ICobuildCompletedState\n ): Promise<void> {\n const { _terminal: terminal } = this;\n const { completedStateKey: key } = context;\n const value: string = this._serializeCompletedState(state);\n const completedStateKeyIdentifier: string = this._getCompletedStateKeyIdentifier(context);\n try {\n await this._redisClient.set(key, value);\n } catch (e) {\n throw new Error(`Failed to set ${completedStateKeyIdentifier}: ${e.message}`);\n }\n terminal.writeDebugLine(`Set ${completedStateKeyIdentifier}: ${value}`);\n }\n\n public async getCompletedStateAsync(context: ICobuildContext): Promise<ICobuildCompletedState | undefined> {\n const { _terminal: terminal } = this;\n const { completedStateKey: key } = context;\n const completedStateKeyIdentifier: string = this._getCompletedStateKeyIdentifier(context);\n let state: ICobuildCompletedState | undefined;\n try {\n const value: string | null = await this._redisClient.get(key);\n if (value) {\n state = this._deserializeCompletedState(value);\n }\n terminal.writeDebugLine(`Get ${completedStateKeyIdentifier}: ${value}`);\n } catch (e) {\n throw new Error(`Failed to get ${completedStateKeyIdentifier}: ${e.message}`);\n }\n return state;\n }\n\n private _serializeCompletedState(state: ICobuildCompletedState): string {\n // Example: SUCCESS;1234567890\n // Example: FAILURE;1234567890\n const { status, cacheId } = state;\n return [status, cacheId].join(COMPLETED_STATE_SEPARATOR);\n }\n\n private _deserializeCompletedState(state: string): ICobuildCompletedState | undefined {\n const [status, cacheId] = state.split(COMPLETED_STATE_SEPARATOR);\n return { status: status as ICobuildCompletedState['status'], cacheId };\n }\n\n private _getLockKeyIdentifier(context: ICobuildContext): string {\n let lockKeyIdentifier: string | undefined = this._lockKeyIdentifierMap.get(context);\n if (lockKeyIdentifier === undefined) {\n const { lockKey, packageName, phaseName } = context;\n lockKeyIdentifier = `lock(${lockKey})_package(${packageName})_phase(${phaseName})`;\n this._lockKeyIdentifierMap.set(context, lockKeyIdentifier);\n }\n return lockKeyIdentifier;\n }\n\n private _getCompletedStateKeyIdentifier(context: ICobuildContext): string {\n let completedStateKeyIdentifier: string | undefined = this._completedStateKeyIdentifierMap.get(context);\n if (completedStateKeyIdentifier === undefined) {\n const { completedStateKey, packageName, phaseName } = context;\n completedStateKeyIdentifier = `completed_state(${completedStateKey})_package(${packageName})_phase(${phaseName})`;\n this._completedStateKeyIdentifierMap.set(context, completedStateKeyIdentifier);\n }\n return completedStateKeyIdentifier;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RushRedisCobuildPlugin.js","sourceRoot":"","sources":["../src/RushRedisCobuildPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAsD;AAItD,MAAM,8BAA8B,GAAgD,0BAAM,CAAC,IAAI,CAC7F,4BAA4B,EAC5B,OAAO,CACR,CAAC;AAEF,MAAM,WAAW,GAAW,oBAAoB,CAAC;AAOjD;;GAEG;AACH,MAAa,sBAAsB;IAKjC,YAAmB,OAAuC;QAJnD,eAAU,GAAW,WAAW,CAAC;QAKtC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,WAAwB,EAAE,iBAAoC;QACzE,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,EAAE;YACjD,WAAW,CAAC,kCAAkC,CAAC,OAAO,EAAE,GAA6B,EAAE;gBACrF,MAAM,OAAO,GAAmC,IAAI,CAAC,QAAQ,CAAC;gBAC9D,OAAO,IAAI,8BAA8B,CAAC,wBAAwB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC3F,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjBD,wDAiBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { Import } from '@rushstack/node-core-library';\r\nimport type { IRushPlugin, RushSession, RushConfiguration } from '@rushstack/rush-sdk';\r\nimport type { IRedisCobuildLockProviderOptions, RedisCobuildLockProvider } from './RedisCobuildLockProvider';\r\n\r\nconst RedisCobuildLockProviderModule: typeof import('./RedisCobuildLockProvider') = Import.lazy(\r\n './RedisCobuildLockProvider',\r\n require\r\n);\r\n\r\nconst PLUGIN_NAME: string = 'RedisCobuildPlugin';\r\n\r\n/**\r\n * @public\r\n */\r\nexport type IRushRedisCobuildPluginOptions = IRedisCobuildLockProviderOptions;\r\n\r\n/**\r\n * @public\r\n */\r\nexport class RushRedisCobuildPlugin implements IRushPlugin {\r\n public pluginName: string = PLUGIN_NAME;\r\n\r\n private _options: IRushRedisCobuildPluginOptions;\r\n\r\n public constructor(options: IRushRedisCobuildPluginOptions) {\r\n this._options = options;\r\n }\r\n\r\n public apply(rushSession: RushSession, rushConfiguration: RushConfiguration): void {\r\n rushSession.hooks.initialize.tap(PLUGIN_NAME, () => {\r\n rushSession.registerCobuildLockProviderFactory('redis', (): RedisCobuildLockProvider => {\r\n const options: IRushRedisCobuildPluginOptions = this._options;\r\n return new RedisCobuildLockProviderModule.RedisCobuildLockProvider(options, rushSession);\r\n });\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RushRedisCobuildPlugin.js","sourceRoot":"","sources":["../src/RushRedisCobuildPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAsD;AAItD,MAAM,8BAA8B,GAAgD,0BAAM,CAAC,IAAI,CAC7F,4BAA4B,EAC5B,OAAO,CACR,CAAC;AAEF,MAAM,WAAW,GAAW,oBAAoB,CAAC;AAOjD;;GAEG;AACH,MAAa,sBAAsB;IAKjC,YAAmB,OAAuC;QAJnD,eAAU,GAAW,WAAW,CAAC;QAKtC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,WAAwB,EAAE,iBAAoC;QACzE,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,EAAE;YACjD,WAAW,CAAC,kCAAkC,CAAC,OAAO,EAAE,GAA6B,EAAE;gBACrF,MAAM,OAAO,GAAmC,IAAI,CAAC,QAAQ,CAAC;gBAC9D,OAAO,IAAI,8BAA8B,CAAC,wBAAwB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC3F,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjBD,wDAiBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Import } from '@rushstack/node-core-library';\nimport type { IRushPlugin, RushSession, RushConfiguration } from '@rushstack/rush-sdk';\nimport type { IRedisCobuildLockProviderOptions, RedisCobuildLockProvider } from './RedisCobuildLockProvider';\n\nconst RedisCobuildLockProviderModule: typeof import('./RedisCobuildLockProvider') = Import.lazy(\n './RedisCobuildLockProvider',\n require\n);\n\nconst PLUGIN_NAME: string = 'RedisCobuildPlugin';\n\n/**\n * @public\n */\nexport type IRushRedisCobuildPluginOptions = IRedisCobuildLockProviderOptions;\n\n/**\n * @public\n */\nexport class RushRedisCobuildPlugin implements IRushPlugin {\n public pluginName: string = PLUGIN_NAME;\n\n private _options: IRushRedisCobuildPluginOptions;\n\n public constructor(options: IRushRedisCobuildPluginOptions) {\n this._options = options;\n }\n\n public apply(rushSession: RushSession, rushConfiguration: RushConfiguration): void {\n rushSession.hooks.initialize.tap(PLUGIN_NAME, () => {\n rushSession.registerCobuildLockProviderFactory('redis', (): RedisCobuildLockProvider => {\n const options: IRushRedisCobuildPluginOptions = this._options;\n return new RedisCobuildLockProviderModule.RedisCobuildLockProvider(options, rushSession);\n });\n });\n }\n}\n"]}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,qEAAkG;AAElG,kBAAe,+CAAsB,CAAC;AACtC,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { RushRedisCobuildPlugin, IRushRedisCobuildPluginOptions } from './RushRedisCobuildPlugin';\r\n\r\nexport default RushRedisCobuildPlugin;\r\nexport { RedisCobuildLockProvider } from './RedisCobuildLockProvider';\r\nexport { IRedisCobuildLockProviderOptions } from './RedisCobuildLockProvider';\r\nexport { IRushRedisCobuildPluginOptions };\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,qEAAkG;AAElG,kBAAe,+CAAsB,CAAC;AACtC,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { RushRedisCobuildPlugin, IRushRedisCobuildPluginOptions } from './RushRedisCobuildPlugin';\n\nexport default RushRedisCobuildPlugin;\nexport { RedisCobuildLockProvider } from './RedisCobuildLockProvider';\nexport { IRedisCobuildLockProviderOptions } from './RedisCobuildLockProvider';\nexport { IRushRedisCobuildPluginOptions };\n"]}
@@ -1,70 +1,70 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "title": "Configuration for cobuild lock with Redis configuration\n\nhttps://github.com/redis/node-redis/blob/master/docs/client-configuration.md",
4
- "type": "object",
5
- "additionalProperties": false,
6
- "properties": {
7
- "url": {
8
- "type": "string",
9
- "description": "redis[s]://[[username][:password]@][host][:port][/db-number]\n\n See the following links for more information:\n\nredis: https://www.iana.org/assignments/uri-schemes/prov/redis\n\nrediss: https://www.iana.org/assignments/uri-schemes/prov/rediss"
10
- },
11
- "socket": {
12
- "type": "object",
13
- "description": "Socket connection properties. Unlisted net.connect properties (and tls.connect) are also supported",
14
- "properties": {
15
- "port": {
16
- "description": "Redis server port. Default value is 6379",
17
- "type": "number"
18
- },
19
- "host": {
20
- "description": "Redis server host. Default value is localhost",
21
- "type": "string"
22
- },
23
- "family": {
24
- "description": "IP Stack version (one of 4 | 6 | 0). Default value is 0",
25
- "type": "number"
26
- },
27
- "path": {
28
- "description": "path to the UNIX Socket",
29
- "type": "string"
30
- },
31
- "connectTimeout": {
32
- "description": "Connection timeout in milliseconds. Default value is 5000",
33
- "type": "number"
34
- },
35
- "noDelay": {
36
- "description": "Toggle Nagle's algorithm. Default value is true",
37
- "type": "boolean"
38
- },
39
- "keepAlive": {
40
- "description": "Toggle keep alive on the socket",
41
- "type": "boolean"
42
- }
43
- }
44
- },
45
- "username": {
46
- "description": "ACL username",
47
- "type": "string"
48
- },
49
- "passwordEnvironmentVariable": {
50
- "description": "The environment variable used to get the ACL password",
51
- "type": "string"
52
- },
53
- "name": {
54
- "description": "Redis client name",
55
- "type": "string"
56
- },
57
- "database": {
58
- "description": "Redis database number",
59
- "type": "number"
60
- },
61
- "legacyMode": {
62
- "description": "Maintain some backwards compatibility",
63
- "type": "boolean"
64
- },
65
- "pingInterval": {
66
- "description": "Send PING command at interval (in ms). Useful with \"Azure Cache for Redis\".",
67
- "type": "number"
68
- }
69
- }
70
- }
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "title": "Configuration for cobuild lock with Redis configuration\n\nhttps://github.com/redis/node-redis/blob/master/docs/client-configuration.md",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "url": {
8
+ "type": "string",
9
+ "description": "redis[s]://[[username][:password]@][host][:port][/db-number]\n\n See the following links for more information:\n\nredis: https://www.iana.org/assignments/uri-schemes/prov/redis\n\nrediss: https://www.iana.org/assignments/uri-schemes/prov/rediss"
10
+ },
11
+ "socket": {
12
+ "type": "object",
13
+ "description": "Socket connection properties. Unlisted net.connect properties (and tls.connect) are also supported",
14
+ "properties": {
15
+ "port": {
16
+ "description": "Redis server port. Default value is 6379",
17
+ "type": "number"
18
+ },
19
+ "host": {
20
+ "description": "Redis server host. Default value is localhost",
21
+ "type": "string"
22
+ },
23
+ "family": {
24
+ "description": "IP Stack version (one of 4 | 6 | 0). Default value is 0",
25
+ "type": "number"
26
+ },
27
+ "path": {
28
+ "description": "path to the UNIX Socket",
29
+ "type": "string"
30
+ },
31
+ "connectTimeout": {
32
+ "description": "Connection timeout in milliseconds. Default value is 5000",
33
+ "type": "number"
34
+ },
35
+ "noDelay": {
36
+ "description": "Toggle Nagle's algorithm. Default value is true",
37
+ "type": "boolean"
38
+ },
39
+ "keepAlive": {
40
+ "description": "Toggle keep alive on the socket",
41
+ "type": "boolean"
42
+ }
43
+ }
44
+ },
45
+ "username": {
46
+ "description": "ACL username",
47
+ "type": "string"
48
+ },
49
+ "passwordEnvironmentVariable": {
50
+ "description": "The environment variable used to get the ACL password",
51
+ "type": "string"
52
+ },
53
+ "name": {
54
+ "description": "Redis client name",
55
+ "type": "string"
56
+ },
57
+ "database": {
58
+ "description": "Redis database number",
59
+ "type": "number"
60
+ },
61
+ "legacyMode": {
62
+ "description": "Maintain some backwards compatibility",
63
+ "type": "boolean"
64
+ },
65
+ "pingInterval": {
66
+ "description": "Send PING command at interval (in ms). Useful with \"Azure Cache for Redis\".",
67
+ "type": "number"
68
+ }
69
+ }
70
+ }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.38.0"
8
+ "packageVersion": "7.38.2"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/rush-redis-cobuild-plugin",
3
- "version": "5.110.0",
3
+ "version": "5.110.1",
4
4
  "description": "Rush plugin for Redis cobuild lock",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,12 +13,12 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@redis/client": "~1.5.5",
16
- "@rushstack/rush-sdk": "5.110.0",
17
- "@rushstack/node-core-library": "3.61.0"
16
+ "@rushstack/node-core-library": "3.61.0",
17
+ "@rushstack/rush-sdk": "5.110.1"
18
18
  },
19
19
  "devDependencies": {
20
- "@microsoft/rush-lib": "5.110.0",
21
- "@rushstack/heft": "0.63.0",
20
+ "@microsoft/rush-lib": "5.110.1",
21
+ "@rushstack/heft": "0.63.1",
22
22
  "local-node-rig": "1.0.0"
23
23
  },
24
24
  "scripts": {
@@ -1,11 +1,11 @@
1
- {
2
- "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-plugin-manifest.schema.json",
3
- "plugins": [
4
- {
5
- "pluginName": "rush-redis-cobuild-plugin",
6
- "description": "Rush plugin for Redis cobuild lock",
7
- "entryPoint": "lib/index.js",
8
- "optionsSchema": "lib/schemas/redis-config.schema.json"
9
- }
10
- ]
11
- }
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-plugin-manifest.schema.json",
3
+ "plugins": [
4
+ {
5
+ "pluginName": "rush-redis-cobuild-plugin",
6
+ "description": "Rush plugin for Redis cobuild lock",
7
+ "entryPoint": "lib/index.js",
8
+ "optionsSchema": "lib/schemas/redis-config.schema.json"
9
+ }
10
+ ]
11
+ }