Fix redis setup
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { InjectQueue } from '@nestjs/bull';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Queue } from 'bull';
|
||||
import { UploadedObjectInfo } from 'minio';
|
||||
import { MinioService } from 'src/minio/minio.service';
|
||||
|
||||
@@ -10,7 +12,10 @@ export class KvService {
|
||||
private readonly kvMetadataPath = `${this.kvPrefix}/${this.kvMetadataFileName}`;
|
||||
private readonly logger: Logger = new Logger(KvService.name);
|
||||
|
||||
constructor(private readonly minioService: MinioService) {}
|
||||
constructor(
|
||||
private readonly minioService: MinioService,
|
||||
@InjectQueue('kv') private kvProcessingQueue: Queue,
|
||||
) {}
|
||||
|
||||
public generateFilePath(namespace: string, key: string): string {
|
||||
return `${this.kvPrefix}/${namespace}/${key}`;
|
||||
@@ -114,9 +119,11 @@ export class KvService {
|
||||
...extraData,
|
||||
secretKey: this.generateSecretKey(),
|
||||
claimed: new Date().toISOString(),
|
||||
namespace,
|
||||
};
|
||||
await this.setMetadataFile(Buffer.from(JSON.stringify(metadata)));
|
||||
this.logger.verbose(`Claimed namespace ${namespace}`);
|
||||
this.kvProcessingQueue.add('namespaceModeration', metadata[namespace]);
|
||||
return metadata[namespace];
|
||||
}
|
||||
|
||||
@@ -139,7 +146,7 @@ export class KvService {
|
||||
throw new Error('Incorrect secret key for namespace');
|
||||
}
|
||||
this.logger.verbose(`Setting ${namespace}/${key}`);
|
||||
return await this.minioService.uploadBuffer(
|
||||
const uploadResult = await this.minioService.uploadBuffer(
|
||||
this.kvBucketName,
|
||||
this.generateFilePath(namespace, key),
|
||||
Buffer.from(value),
|
||||
@@ -149,6 +156,7 @@ export class KvService {
|
||||
...options,
|
||||
},
|
||||
);
|
||||
return uploadResult;
|
||||
}
|
||||
|
||||
public async delete(namespace: string, key: string): Promise<void> {
|
||||
|
Reference in New Issue
Block a user