Browse Source

refactor(core): Rename some args

Michael Bromley 4 years ago
parent
commit
a5f3659676

+ 10 - 10
packages/core/src/job-queue/job-buffer/in-memory-job-buffer-storage-strategy.ts

@@ -5,15 +5,15 @@ import { JobBufferStorageStrategy } from './job-buffer-storage-strategy';
 export class InMemoryJobBufferStorageStrategy implements JobBufferStorageStrategy {
 export class InMemoryJobBufferStorageStrategy implements JobBufferStorageStrategy {
     private bufferStorage = new Map<string, Set<Job>>();
     private bufferStorage = new Map<string, Set<Job>>();
 
 
-    async add(processorId: string, job: Job): Promise<Job> {
-        const set = this.getSet(processorId);
+    async add(bufferId: string, job: Job): Promise<Job> {
+        const set = this.getSet(bufferId);
         set.add(job);
         set.add(job);
         return job;
         return job;
     }
     }
 
 
-    async bufferSize(processorIds?: string[]): Promise<{ [processorId: string]: number }> {
-        const ids = processorIds ?? Array.from(this.bufferStorage.keys());
-        const result: { [processorId: string]: number } = {};
+    async bufferSize(bufferIds?: string[]): Promise<{ [bufferId: string]: number }> {
+        const ids = bufferIds ?? Array.from(this.bufferStorage.keys());
+        const result: { [bufferId: string]: number } = {};
         for (const id of ids) {
         for (const id of ids) {
             const size = this.bufferStorage.get(id)?.size ?? 0;
             const size = this.bufferStorage.get(id)?.size ?? 0;
             result[id] = size;
             result[id] = size;
@@ -21,8 +21,8 @@ export class InMemoryJobBufferStorageStrategy implements JobBufferStorageStrateg
         return result;
         return result;
     }
     }
 
 
-    async flush(processorIds?: string[]): Promise<{ [processorId: string]: Job[] }> {
-        const ids = processorIds ?? Array.from(this.bufferStorage.keys());
+    async flush(bufferIds?: string[]): Promise<{ [bufferId: string]: Job[] }> {
+        const ids = bufferIds ?? Array.from(this.bufferStorage.keys());
         const result: { [processorId: string]: Job[] } = {};
         const result: { [processorId: string]: Job[] } = {};
         for (const id of ids) {
         for (const id of ids) {
             const jobs = Array.from(this.bufferStorage.get(id) ?? []);
             const jobs = Array.from(this.bufferStorage.get(id) ?? []);
@@ -32,13 +32,13 @@ export class InMemoryJobBufferStorageStrategy implements JobBufferStorageStrateg
         return result;
         return result;
     }
     }
 
 
-    private getSet(processorId: string): Set<Job> {
-        const set = this.bufferStorage.get(processorId);
+    private getSet(bufferId: string): Set<Job> {
+        const set = this.bufferStorage.get(bufferId);
         if (set) {
         if (set) {
             return set;
             return set;
         } else {
         } else {
             const newSet = new Set<Job>();
             const newSet = new Set<Job>();
-            this.bufferStorage.set(processorId, newSet);
+            this.bufferStorage.set(bufferId, newSet);
             return newSet;
             return newSet;
         }
         }
     }
     }

+ 1 - 1
packages/core/src/job-queue/job-buffer/job-buffer-storage-strategy.ts

@@ -2,7 +2,7 @@ import { InjectableStrategy } from '../../common/types/injectable-strategy';
 import { Job } from '../job';
 import { Job } from '../job';
 
 
 export interface JobBufferStorageStrategy extends InjectableStrategy {
 export interface JobBufferStorageStrategy extends InjectableStrategy {
-    add(processorId: string, job: Job): Promise<Job>;
+    add(bufferId: string, job: Job): Promise<Job>;
     bufferSize(bufferIds?: string[]): Promise<{ [bufferId: string]: number }>;
     bufferSize(bufferIds?: string[]): Promise<{ [bufferId: string]: number }>;
     flush(bufferIds?: string[]): Promise<{ [bufferId: string]: Job[] }>;
     flush(bufferIds?: string[]): Promise<{ [bufferId: string]: Job[] }>;
 }
 }