Skip to content

Commit

Permalink
style(driver): change from item to jobs in jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed May 15, 2024
1 parent bb63fba commit 8fd919b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
14 changes: 7 additions & 7 deletions src/drivers/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,23 @@ export abstract class Driver<Client = any> {
}

/**
* Add a item to the queue.
* Add a job to the queue.
*/
public abstract add(item: unknown): Promise<void>
public abstract add(data: unknown): Promise<void>

/**
* Remove the first item from the queue and return.
* Remove the first job from the queue and return.
*/
public abstract pop<T = any>(): Promise<T>

/**
* Get the first item from the queue without removing
* Get the first job from the queue without removing
* and return.
*/
public abstract peek<T = any>(): Promise<T>

/**
* Return the length of items inside the queue.
* Return the length of jobs inside the queue.
*/
public abstract length(): Promise<number>

Expand All @@ -134,9 +134,9 @@ export abstract class Driver<Client = any> {
public abstract isEmpty(): Promise<boolean>

/**
* Process the next item in the queue.
* Process the next data in the queue.
*/
public abstract process(
processor: (item: unknown) => any | Promise<any>
processor: (data: unknown) => any | Promise<any>
): Promise<void>
}
26 changes: 14 additions & 12 deletions src/drivers/FakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class FakeDriver {
}

/**
* Add a new item to the queue.
* Add a new job to the queue.
*
* @example
* ```ts
Expand All @@ -139,7 +139,7 @@ export class FakeDriver {
public static async add() {}

/**
* Remove an item from the queue and return.
* Remove an job from the queue and return.
*
* @example
* ```ts
Expand All @@ -153,7 +153,7 @@ export class FakeDriver {
}

/**
* Remove an item from the queue and return.
* Remove an job from the queue and return.
*
* @example
* ```ts
Expand All @@ -167,7 +167,7 @@ export class FakeDriver {
}

/**
* Return how many items are defined inside the queue.
* Return how many jobs are defined inside the queue.
*
* @example
* ```ts
Expand All @@ -183,7 +183,7 @@ export class FakeDriver {
}

/**
* Verify if there are items on the queue.
* Verify if there are jobs on the queue.
*
* @example
* ```ts
Expand All @@ -196,7 +196,7 @@ export class FakeDriver {
}

/**
* Process the next item of the queue with a handler.
* Process the next job of the queue with a handler.
*
* @example
* ```ts
Expand All @@ -208,18 +208,20 @@ export class FakeDriver {
* ```
*/
public static async process(
processor: (item: unknown) => any | Promise<any>
processor: (data: unknown) => any | Promise<any>
) {
const data = await this.pop()

try {
await processor(data)
} catch (err) {
Log.channelOrVanilla('application').error(
'adding data of %s to deadletter queue due to: %o',
this.queueName,
err
)
if (Config.is('rc.bootLogs', true)) {
Log.channelOrVanilla('application').error(
'adding data of %s to deadletter queue due to: %o',
this.queueName,
err
)
}
}
}
}
28 changes: 15 additions & 13 deletions src/drivers/VanillaDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ export class VanillaDriver extends Driver {
* await Queue.queue('mail').add({ email: 'lenon@athenna.io' })
* ```
*/
public async add(item: unknown) {
public async add(data: unknown) {
this.defineQueue()

this.client.queues[this.queueName].push(item)
this.client.queues[this.queueName].push(data)
}

/**
* Remove an item from the queue and return.
* Remove an job from the queue and return.
*
* @example
* ```ts
Expand All @@ -125,7 +125,7 @@ export class VanillaDriver extends Driver {
}

/**
* Remove an item from the queue and return.
* Remove an job from the queue and return.
*
* @example
* ```ts
Expand All @@ -145,7 +145,7 @@ export class VanillaDriver extends Driver {
}

/**
* Return how many items are defined inside the queue.
* Return how many jobs are defined inside the queue.
*
* @example
* ```ts
Expand All @@ -161,7 +161,7 @@ export class VanillaDriver extends Driver {
}

/**
* Verify if there are items on the queue.
* Verify if there are jobs on the queue.
*
* @example
* ```ts
Expand All @@ -176,7 +176,7 @@ export class VanillaDriver extends Driver {
}

/**
* Process the next item of the queue with a handler.
* Process the next job of the queue with a handler.
*
* @example
* ```ts
Expand All @@ -187,17 +187,19 @@ export class VanillaDriver extends Driver {
* })
* ```
*/
public async process(processor: (item: unknown) => any | Promise<any>) {
public async process(processor: (data: unknown) => any | Promise<any>) {
const data = await this.pop()

try {
await processor(data)
} catch (err) {
Log.channelOrVanilla('application').error(
'adding data of %s to deadletter queue due to: %o',
this.queueName,
err
)
if (Config.is('rc.bootLogs', true)) {
Log.channelOrVanilla('application').error(
'adding data of %s to deadletter queue due to: %o',
this.queueName,
err
)
}

this.client.queues[this.deadletter].push({ queue: this.queueName, data })
}
Expand Down

0 comments on commit 8fd919b

Please sign in to comment.