Skip to content

Commit c96d91e

Browse files
committed
refactor: remove all disconnect features
1 parent 6e6ff05 commit c96d91e

11 files changed

Lines changed: 0 additions & 75 deletions

File tree

docs/content/docs/api.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,6 @@ const lock1 = verrou.createLock('key', 'owner')
156156
const lock2 = verrou.restoreLock(lock1.serialize())
157157
```
158158

159-
### `disconnect`
160-
161-
Disconnect from the store if applicable. With a Redis Store, it will close the `ioredis` connection.
162-
163-
```ts
164-
await verrou.disconnect()
165-
```
166-
167159
## Verrou API
168160

169161
Verrou API is a wrapper around the LockFactory API.
@@ -200,11 +192,3 @@ As explained above, the `use` method allows you to use a different store than th
200192
verrou.use('myMemoryStore').createLock('key')
201193
```
202194

203-
### `disconnectAll`
204-
205-
Disconnect from all stores.
206-
207-
```ts
208-
await verrou.disconnectAll()
209-
```
210-

docs/content/docs/extend/custom_lock_store.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ interface LockStore {
1212
delete(key: string, owner: string): Promise<void>
1313
exists(key: string): Promise<boolean>
1414
extend(key: string, owner: string, duration: number): Promise<void>
15-
disconnect(): Promise<void>
1615
}
1716
```
1817

packages/verrou/src/drivers/database.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,4 @@ export class DatabaseStore {
105105

106106
return lock.expiration > Date.now()
107107
}
108-
109-
async disconnect() {}
110108
}

packages/verrou/src/drivers/dynamodb.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,4 @@ export class DynamoDBStore implements LockStore {
166166
throw new E_LOCK_NOT_OWNED()
167167
}
168168
}
169-
170-
/**
171-
* Disconnect from DynamoDB
172-
*/
173-
async disconnect() {
174-
this.#client.destroy()
175-
}
176169
}

packages/verrou/src/drivers/memory.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,4 @@ export class MemoryStore implements LockStore {
109109

110110
return lock.mutex.isLocked()
111111
}
112-
113-
async disconnect() {
114-
// noop
115-
}
116112
}

packages/verrou/src/drivers/redis.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,4 @@ export class RedisStore implements LockStore {
8585
const result = await this.#connection.eval(lua, 1, key, owner, duration)
8686
if (result === 0) throw new E_LOCK_NOT_OWNED()
8787
}
88-
89-
/**
90-
* Disconnect from Redis
91-
*/
92-
async disconnect() {
93-
await this.#connection.quit()
94-
}
9588
}

packages/verrou/src/lock_factory.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,4 @@ export class LockFactory {
6060
restoreLock(lock: SerializedLock) {
6161
return new Lock(lock.key, this.#store, this.#config, lock.owner, lock.ttl, lock.expirationTime)
6262
}
63-
64-
/**
65-
* Disconnect the store ( if applicable )
66-
*/
67-
disconnect() {
68-
return this.#store.disconnect()
69-
}
7063
}

packages/verrou/src/types/main.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,4 @@ export interface LockStore {
110110
* Duration is in milliseconds
111111
*/
112112
extend(key: string, owner: string, duration: number): Promise<void>
113-
114-
/**
115-
* Disconnect the store from the underlying storage ( when applicable )
116-
*/
117-
disconnect(): Promise<void>
118113
}

packages/verrou/src/verrou.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,4 @@ export class Verrou<KnownStores extends Record<string, StoreFactory>> {
7070
restoreLock(lock: SerializedLock) {
7171
return this.use(this.#defaultStoreName).restoreLock(lock)
7272
}
73-
74-
/**
75-
* Disconnect the default store
76-
*/
77-
async disconnect() {
78-
await this.use(this.#defaultStoreName).disconnect()
79-
}
80-
81-
/**
82-
* Disconnect all connections to the stores
83-
*/
84-
async disconnectAll() {
85-
const promises = []
86-
87-
for (const store of this.#storesCache.values()) {
88-
promises.push(store.disconnect())
89-
}
90-
91-
await Promise.allSettled(promises)
92-
}
9373
}

packages/verrou/test_helpers/null_store.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,4 @@ export class NullStore implements LockStore {
2424
async extend(_key: string, _owner: string, _duration: number): Promise<void> {
2525
return
2626
}
27-
28-
async disconnect() {
29-
return
30-
}
3127
}

0 commit comments

Comments
 (0)