* Get information about a lock * @param lockName - Name of the lock * @returns Promise - Lock information or null if not locked
(lockName: string)
| 305 | * @returns Promise<LockInfo | null> - Lock information or null if not locked |
| 306 | */ |
| 307 | async getLockInfo(lockName: string): Promise<{ |
| 308 | id: string; |
| 309 | acquiredAt: number; |
| 310 | acquiredBy: string; |
| 311 | age: number; |
| 312 | } | null> { |
| 313 | try { |
| 314 | const cacheManager = await getCacheManager(); |
| 315 | const lockKey = `${this.options.prefix}:${lockName}`; |
| 316 | const existingLock = await cacheManager.get(lockKey); |
| 317 | |
| 318 | if (!existingLock) { |
| 319 | return null; |
| 320 | } |
| 321 | |
| 322 | const parsedLock = JSON.parse(String(existingLock)); |
| 323 | return { |
| 324 | ...parsedLock, |
| 325 | age: Date.now() - parsedLock.acquiredAt, |
| 326 | }; |
| 327 | } catch (error) { |
| 328 | logger.error( |
| 329 | `[DistributedLock] Error getting lock info ${lockName}:`, |
| 330 | error |
| 331 | ); |
| 332 | return null; |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | // Default instance for convenience |
nothing calls this directly
no test coverage detected