lykmapipo / kue-scheduler

A job scheduler utility for kue, backed by redis and built for node.js
246 stars 47 forks source link

Usage with Typescript does not work for unique jobs #128

Closed heniotierra closed 5 years ago

heniotierra commented 5 years ago

I am using this lib along with Typescript, but if I try the example to create a unique Job instance, I get the following message from ts compiler:

The property 'unique' does not exist in type 'Job'.

This is the code:

      var options = {
        prefix: 'w',
        redis: {
          port: +process.env.KUE_REDIS_PORT,
          host: process.env.KUE_REDIS_HOST,
          db: process.env.KUE_REDIS_DB
        },
        restore: true
      };

      const Queue = kue.createQueue(options);

      const job = Queue
        .createJob('unique-every', null)
        .attempts(attempts)
        .backoff({
          delay: backoff,
          type: 'fixed'
        })
        .priority('normal')
        .unique('unique-every');

      Queue.every('5 seconds', job);

      Queue.process('queue-control', this.viabilityTasks.viabilityComputationQueueControl);

How can I get this to work?

Thanks,

lykmapipo commented 5 years ago

@heniotierra May be it missing from type definition. I will appreciate PR for the fix.

heniotierra commented 5 years ago

@lykmapipo I have fixed it, but it required a patch to https://github.com/lykmapipo/kue-unique as well. Will send the PRs.

heniotierra commented 5 years ago

These are the PRs: https://github.com/lykmapipo/kue-scheduler/pull/129 https://github.com/lykmapipo/kue-unique/pull/11

lykmapipo commented 5 years ago

@heniotierra On it.