Skip to content

Commit

Permalink
Merge bc763f7 into ad3edcf
Browse files Browse the repository at this point in the history
  • Loading branch information
BelgianNoise committed Mar 24, 2022
2 parents ad3edcf + bc763f7 commit fda32b2
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 64 deletions.
174 changes: 127 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"@types/cors": "^2.8.12",
"@types/end-of-stream": "^1.4.1",
"@types/fs-extra": "^9.0.13",
"@types/ioredis": "^4.28.10",
"@types/lodash.orderby": "^4.6.6",
"@types/marked": "^4.0.2",
"@types/mime-types": "^2.1.1",
Expand All @@ -92,7 +93,6 @@
"@types/oidc-provider": "^7.8.1",
"@types/pump": "^1.1.1",
"@types/punycode": "^2.1.0",
"@types/redis": "^2.8.30",
"@types/redlock": "^4.0.1",
"@types/sparqljs": "^3.1.3",
"@types/url-join": "^4.0.1",
Expand All @@ -111,6 +111,7 @@
"fetch-sparql-endpoint": "^2.4.0",
"fs-extra": "^10.0.0",
"handlebars": "^4.7.7",
"ioredis": "^4.28.5",
"jose": "^4.4.0",
"lodash.orderby": "^4.6.0",
"marked": "^4.0.12",
Expand All @@ -124,7 +125,6 @@
"rdf-parse": "^1.9.1",
"rdf-serialize": "^1.2.0",
"rdf-terms": "^1.7.1",
"redis": "^3.1.2",
"redlock": "^4.2.0",
"sparqlalgebrajs": "^4.0.2",
"sparqljs": "^3.5.1",
Expand Down
14 changes: 7 additions & 7 deletions src/util/locking/RedisResourceLocker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from 'console';
import type { RedisClient } from 'redis';
import { createClient } from 'redis';
import Redis from 'ioredis';
import type { Redis as RedisType } from 'ioredis';
import type { Lock } from 'redlock';
import Redlock from 'redlock';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
Expand Down Expand Up @@ -46,7 +46,7 @@ export class RedisResourceLocker implements ResourceLocker, Finalizable {

public constructor(redisClients: string[], redlockOptions?: Record<string, number>) {
this.lockMap = new Map();
const clients = this.createRedisClients(redisClients);
const clients: RedisType[] = this.createRedisClients(redisClients);
if (clients.length === 0) {
throw new Error('At least 1 client should be provided');
}
Expand All @@ -61,8 +61,8 @@ export class RedisResourceLocker implements ResourceLocker, Finalizable {
* @param redisClientsStrings - a list of strings that contain either a host address and a
* port number like '127.0.0.1:6379' or just a port number like '6379'
*/
private createRedisClients(redisClientsStrings: string[]): RedisClient[] {
const result: RedisClient[] = [];
private createRedisClients(redisClientsStrings: string[]): RedisType[] {
const result: RedisType[] = [];
if (redisClientsStrings && redisClientsStrings.length > 0) {
for (const client of redisClientsStrings) {
// Check if port number or ip with port number
Expand All @@ -75,7 +75,7 @@ export class RedisResourceLocker implements ResourceLocker, Finalizable {
}
const port = Number(match[2]);
const host = match[1];
const redisclient = createClient(port, host);
const redisclient: RedisType = new Redis(port, host);
result.push(redisclient);
}
}
Expand All @@ -87,7 +87,7 @@ export class RedisResourceLocker implements ResourceLocker, Finalizable {
* @param clients - a list of RedisClients you want to use for the redlock instance
* @param redlockOptions - extra redlock options to overwrite the default config
*/
private createRedlock(clients: RedisClient[], redlockOptions: Record<string, number> = {}): Redlock {
private createRedlock(clients: RedisType[], redlockOptions: Record<string, number> = {}): Redlock {
try {
return new Redlock(
clients,
Expand Down
Loading

0 comments on commit fda32b2

Please sign in to comment.