From dacfb74a6a0cd07c35923fb513cdb299a67451b6 Mon Sep 17 00:00:00 2001 From: smessie Date: Tue, 17 Nov 2020 14:58:00 +0100 Subject: [PATCH] refactor: Move lock stuff in its own folder --- src/storage/LockingResourceStore.ts | 4 ++-- src/storage/patch/SparqlUpdatePatchHandler.ts | 2 +- src/{storage => util/locking}/ExpiringLock.ts | 0 src/{storage => util/locking}/ExpiringResourceLocker.ts | 0 src/{storage => util/locking}/Lock.ts | 0 src/{storage => util/locking}/ResourceLocker.ts | 2 +- .../locking}/SingleThreadedResourceLocker.ts | 4 ++-- src/{storage => util/locking}/WrappedExpiringLock.ts | 2 +- .../locking}/WrappedExpiringResourceLocker.ts | 4 ++-- test/unit/storage/LockingResourceStore.test.ts | 6 +++--- test/unit/storage/patch/SparqlUpdatePatchHandler.test.ts | 4 ++-- .../locking}/SingleThreadedResourceLocker.test.ts | 2 +- .../locking}/WrappedExpiringResourceLocker.test.ts | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) rename src/{storage => util/locking}/ExpiringLock.ts (100%) rename src/{storage => util/locking}/ExpiringResourceLocker.ts (100%) rename src/{storage => util/locking}/Lock.ts (100%) rename src/{storage => util/locking}/ResourceLocker.ts (83%) rename src/{storage => util/locking}/SingleThreadedResourceLocker.ts (89%) rename src/{storage => util/locking}/WrappedExpiringLock.ts (97%) rename src/{storage => util/locking}/WrappedExpiringResourceLocker.ts (90%) rename test/unit/{storage => util/locking}/SingleThreadedResourceLocker.test.ts (95%) rename test/unit/{storage => util/locking}/WrappedExpiringResourceLocker.test.ts (89%) diff --git a/src/storage/LockingResourceStore.ts b/src/storage/LockingResourceStore.ts index f654e0210..d67366a71 100644 --- a/src/storage/LockingResourceStore.ts +++ b/src/storage/LockingResourceStore.ts @@ -5,10 +5,10 @@ import type { RepresentationPreferences } from '../ldp/representation/Representa import type { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier'; import { getLoggerFor } from '../logging/LogUtil'; import type { Guarded } from '../util/GuardedStream'; +import type { ExpiringLock } from '../util/locking/ExpiringLock'; +import type { ExpiringResourceLocker } from '../util/locking/ExpiringResourceLocker'; import type { AtomicResourceStore } from './AtomicResourceStore'; import type { Conditions } from './Conditions'; -import type { ExpiringLock } from './ExpiringLock'; -import type { ExpiringResourceLocker } from './ExpiringResourceLocker'; import type { ResourceStore } from './ResourceStore'; /** diff --git a/src/storage/patch/SparqlUpdatePatchHandler.ts b/src/storage/patch/SparqlUpdatePatchHandler.ts index 23b0b4924..9c5ff6ff1 100644 --- a/src/storage/patch/SparqlUpdatePatchHandler.ts +++ b/src/storage/patch/SparqlUpdatePatchHandler.ts @@ -12,8 +12,8 @@ import { getLoggerFor } from '../../logging/LogUtil'; import { INTERNAL_QUADS } from '../../util/ContentTypes'; import { UnsupportedHttpError } from '../../util/errors/UnsupportedHttpError'; import { guardStream } from '../../util/GuardedStream'; +import type { ResourceLocker } from '../../util/locking/ResourceLocker'; import { CONTENT_TYPE } from '../../util/UriConstants'; -import type { ResourceLocker } from '../ResourceLocker'; import type { ResourceStore } from '../ResourceStore'; import { PatchHandler } from './PatchHandler'; diff --git a/src/storage/ExpiringLock.ts b/src/util/locking/ExpiringLock.ts similarity index 100% rename from src/storage/ExpiringLock.ts rename to src/util/locking/ExpiringLock.ts diff --git a/src/storage/ExpiringResourceLocker.ts b/src/util/locking/ExpiringResourceLocker.ts similarity index 100% rename from src/storage/ExpiringResourceLocker.ts rename to src/util/locking/ExpiringResourceLocker.ts diff --git a/src/storage/Lock.ts b/src/util/locking/Lock.ts similarity index 100% rename from src/storage/Lock.ts rename to src/util/locking/Lock.ts diff --git a/src/storage/ResourceLocker.ts b/src/util/locking/ResourceLocker.ts similarity index 83% rename from src/storage/ResourceLocker.ts rename to src/util/locking/ResourceLocker.ts index 8558b9f98..68b36483e 100644 --- a/src/storage/ResourceLocker.ts +++ b/src/util/locking/ResourceLocker.ts @@ -1,4 +1,4 @@ -import type { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier'; +import type { ResourceIdentifier } from '../../ldp/representation/ResourceIdentifier'; import type { Lock } from './Lock'; /** diff --git a/src/storage/SingleThreadedResourceLocker.ts b/src/util/locking/SingleThreadedResourceLocker.ts similarity index 89% rename from src/storage/SingleThreadedResourceLocker.ts rename to src/util/locking/SingleThreadedResourceLocker.ts index 3a302e9f1..e981d25f5 100644 --- a/src/storage/SingleThreadedResourceLocker.ts +++ b/src/util/locking/SingleThreadedResourceLocker.ts @@ -1,6 +1,6 @@ import AsyncLock from 'async-lock'; -import type { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; +import type { ResourceIdentifier } from '../../ldp/representation/ResourceIdentifier'; +import { getLoggerFor } from '../../logging/LogUtil'; import type { Lock } from './Lock'; import type { ResourceLocker } from './ResourceLocker'; diff --git a/src/storage/WrappedExpiringLock.ts b/src/util/locking/WrappedExpiringLock.ts similarity index 97% rename from src/storage/WrappedExpiringLock.ts rename to src/util/locking/WrappedExpiringLock.ts index 375b55788..ef2f511af 100644 --- a/src/storage/WrappedExpiringLock.ts +++ b/src/util/locking/WrappedExpiringLock.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'events'; -import { getLoggerFor } from '../logging/LogUtil'; +import { getLoggerFor } from '../../logging/LogUtil'; import type { ExpiringLock } from './ExpiringLock'; import type { Lock } from './Lock'; diff --git a/src/storage/WrappedExpiringResourceLocker.ts b/src/util/locking/WrappedExpiringResourceLocker.ts similarity index 90% rename from src/storage/WrappedExpiringResourceLocker.ts rename to src/util/locking/WrappedExpiringResourceLocker.ts index d32087bcc..e89afcb4d 100644 --- a/src/storage/WrappedExpiringResourceLocker.ts +++ b/src/util/locking/WrappedExpiringResourceLocker.ts @@ -1,5 +1,5 @@ -import type { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier'; -import { getLoggerFor } from '../logging/LogUtil'; +import type { ResourceIdentifier } from '../../ldp/representation/ResourceIdentifier'; +import { getLoggerFor } from '../../logging/LogUtil'; import type { ExpiringLock } from './ExpiringLock'; import type { ExpiringResourceLocker } from './ExpiringResourceLocker'; import type { ResourceLocker } from './ResourceLocker'; diff --git a/test/unit/storage/LockingResourceStore.test.ts b/test/unit/storage/LockingResourceStore.test.ts index cd14c0477..b2d682162 100644 --- a/test/unit/storage/LockingResourceStore.test.ts +++ b/test/unit/storage/LockingResourceStore.test.ts @@ -2,11 +2,11 @@ import type { EventEmitter } from 'events'; import streamifyArray from 'streamify-array'; import type { Patch } from '../../../src/ldp/http/Patch'; import type { Representation } from '../../../src/ldp/representation/Representation'; -import type { ExpiringLock } from '../../../src/storage/ExpiringLock'; -import type { ExpiringResourceLocker } from '../../../src/storage/ExpiringResourceLocker'; import { LockingResourceStore } from '../../../src/storage/LockingResourceStore'; import type { ResourceStore } from '../../../src/storage/ResourceStore'; -import { WrappedExpiringResourceLocker } from '../../../src/storage/WrappedExpiringResourceLocker'; +import type { ExpiringLock } from '../../../src/util/locking/ExpiringLock'; +import type { ExpiringResourceLocker } from '../../../src/util/locking/ExpiringResourceLocker'; +import { WrappedExpiringResourceLocker } from '../../../src/util/locking/WrappedExpiringResourceLocker'; describe('A LockingResourceStore', (): void => { let store: LockingResourceStore; diff --git a/test/unit/storage/patch/SparqlUpdatePatchHandler.test.ts b/test/unit/storage/patch/SparqlUpdatePatchHandler.test.ts index 8ef80a311..42b4bb397 100644 --- a/test/unit/storage/patch/SparqlUpdatePatchHandler.test.ts +++ b/test/unit/storage/patch/SparqlUpdatePatchHandler.test.ts @@ -5,12 +5,12 @@ import { translate } from 'sparqlalgebrajs'; import streamifyArray from 'streamify-array'; import type { SparqlUpdatePatch } from '../../../../src/ldp/http/SparqlUpdatePatch'; import { RepresentationMetadata } from '../../../../src/ldp/representation/RepresentationMetadata'; -import type { Lock } from '../../../../src/storage/Lock'; import { SparqlUpdatePatchHandler } from '../../../../src/storage/patch/SparqlUpdatePatchHandler'; -import type { ResourceLocker } from '../../../../src/storage/ResourceLocker'; import type { ResourceStore } from '../../../../src/storage/ResourceStore'; import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes'; import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError'; +import type { Lock } from '../../../../src/util/locking/Lock'; +import type { ResourceLocker } from '../../../../src/util/locking/ResourceLocker'; describe('A SparqlUpdatePatchHandler', (): void => { let handler: SparqlUpdatePatchHandler; diff --git a/test/unit/storage/SingleThreadedResourceLocker.test.ts b/test/unit/util/locking/SingleThreadedResourceLocker.test.ts similarity index 95% rename from test/unit/storage/SingleThreadedResourceLocker.test.ts rename to test/unit/util/locking/SingleThreadedResourceLocker.test.ts index 6cea9aeb2..8fbdb6cb7 100644 --- a/test/unit/storage/SingleThreadedResourceLocker.test.ts +++ b/test/unit/util/locking/SingleThreadedResourceLocker.test.ts @@ -1,4 +1,4 @@ -import { SingleThreadedResourceLocker } from '../../../src/storage/SingleThreadedResourceLocker'; +import { SingleThreadedResourceLocker } from '../../../../src/util/locking/SingleThreadedResourceLocker'; describe('A SingleThreadedResourceLocker', (): void => { let locker: SingleThreadedResourceLocker; diff --git a/test/unit/storage/WrappedExpiringResourceLocker.test.ts b/test/unit/util/locking/WrappedExpiringResourceLocker.test.ts similarity index 89% rename from test/unit/storage/WrappedExpiringResourceLocker.test.ts rename to test/unit/util/locking/WrappedExpiringResourceLocker.test.ts index f84e3aabd..ebdb13aa9 100644 --- a/test/unit/storage/WrappedExpiringResourceLocker.test.ts +++ b/test/unit/util/locking/WrappedExpiringResourceLocker.test.ts @@ -1,4 +1,4 @@ -import { WrappedExpiringResourceLocker } from '../../../src/storage/WrappedExpiringResourceLocker'; +import { WrappedExpiringResourceLocker } from '../../../../src/util/locking/WrappedExpiringResourceLocker'; describe('A WrappedExpiringResourceLocker', (): void => { it('emits an error event when releasing the lock errors.', async(): Promise => {