🚨 Announcing Vendure v2 Beta

PollingJobQueueStrategy

PollingJobQueueStrategy

This class allows easier implementation of JobQueueStrategy in a polling style. Instead of providing JobQueueStrategy start() you should provide a next method.

This class should be extended by any strategy which does not support a push-based system to notify on new jobs. It is used by the SqlJobQueueStrategy and InMemoryJobQueueStrategy.

Signature

class PollingJobQueueStrategy extends InjectableJobQueueStrategy {
  public public concurrency: number;
  public public pollInterval: number | ((queueName: string) => number);
  public public setRetries: (queueName: string, job: Job) => number;
  public public backOffStrategy?: BackoffStrategy;
  constructor(config?: PollingJobQueueStrategyConfig)
  constructor(concurrency?: number, pollInterval?: number)
  constructor(concurrencyOrConfig?: number | PollingJobQueueStrategyConfig, maybePollInterval?: number)
  async start(queueName: string, process: (job: Job<Data>) => Promise<any>) => ;
  async stop(queueName: string, process: (job: Job<Data>) => Promise<any>) => ;
  async cancelJob(jobId: ID) => Promise<Job | undefined>;
  abstract next(queueName: string) => Promise<Job | undefined>;
  abstract update(job: Job) => Promise<void>;
  abstract findOne(id: ID) => Promise<Job | undefined>;
}

Extends

  • InjectableJobQueueStrategy

Members

concurrency

public property
type:
number

pollInterval

public property
type:
number | ((queueName: string) => number)

setRetries

public property
type:
(queueName: string, job: Job) => number

backOffStrategy

public property

constructor

method
type:
(config?: PollingJobQueueStrategyConfig) => PollingJobQueueStrategy

constructor

method
type:
(concurrency?: number, pollInterval?: number) => PollingJobQueueStrategy

constructor

method
type:
(concurrencyOrConfig?: number | PollingJobQueueStrategyConfig, maybePollInterval?: number) => PollingJobQueueStrategy

start

async method
type:
(queueName: string, process: (job: Job<Data>) => Promise<any>) =>

stop

async method
type:
(queueName: string, process: (job: Job<Data>) => Promise<any>) =>

cancelJob

async method
type:
(jobId: ID) => Promise<Job | undefined>

next

abstract method
type:
(queueName: string) => Promise<Job | undefined>
Should return the next job in the given queue. The implementation is responsible for returning the correct job according to the time of creation.

update

abstract method
type:
(job: Job) => Promise<void>
Update the job details in the store.

findOne

abstract method
type:
(id: ID) => Promise<Job | undefined>
Returns a job by its id.