base-job-options.d.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { BackoffOptions } from './backoff-options';
  2. import { KeepJobs } from '../types/keep-jobs';
  3. import { ParentOptions } from './parent-options';
  4. import { RepeatOptions } from './repeat-options';
  5. export interface DefaultJobOptions {
  6. /**
  7. * Timestamp when the job was created.
  8. * @defaultValue Date.now()
  9. */
  10. timestamp?: number;
  11. /**
  12. * Ranges from 0 (highest priority) to 2 097 152 (lowest priority). Note that
  13. * using priorities has a slight impact on performance,
  14. * so do not use it if not required.
  15. * @defaultValue 0
  16. */
  17. priority?: number;
  18. /**
  19. * An amount of milliseconds to wait until this job can be processed.
  20. * Note that for accurate delays, worker and producers
  21. * should have their clocks synchronized.
  22. * @defaultValue 0
  23. */
  24. delay?: number;
  25. /**
  26. * The total number of attempts to try the job until it completes.
  27. * @defaultValue 1
  28. */
  29. attempts?: number;
  30. /**
  31. * Backoff setting for automatic retries if the job fails
  32. */
  33. backoff?: number | BackoffOptions;
  34. /**
  35. * If true, adds the job to the right of the queue instead of the left (default false)
  36. *
  37. * @see {@link https://docs.bullmq.io/guide/jobs/lifo}
  38. */
  39. lifo?: boolean;
  40. /**
  41. * If true, removes the job when it successfully completes
  42. * When given a number, it specifies the maximum amount of
  43. * jobs to keep, or you can provide an object specifying max
  44. * age and/or count to keep. It overrides whatever setting is used in the worker.
  45. * Default behavior is to keep the job in the completed set.
  46. *
  47. * When using `age` or `count`, the eviction is evaluated on a
  48. * best-effort basis every time a job finishes; BullMQ does not run a
  49. * background timer, so aged jobs are only removed once another job
  50. * completes after their expiration.
  51. */
  52. removeOnComplete?: boolean | number | KeepJobs;
  53. /**
  54. * If true, removes the job when it fails after all attempts.
  55. * When given a number, it specifies the maximum amount of
  56. * jobs to keep, or you can provide an object specifying max
  57. * age and/or count to keep. It overrides whatever setting is used in the worker.
  58. * Default behavior is to keep the job in the failed set.
  59. *
  60. * When using `age` or `count`, the eviction is evaluated on a
  61. * best-effort basis every time a job fails; BullMQ does not run a
  62. * background timer, so aged jobs are only removed once another job
  63. * fails after their expiration.
  64. */
  65. removeOnFail?: boolean | number | KeepJobs;
  66. /**
  67. * Maximum amount of log entries that will be preserved
  68. */
  69. keepLogs?: number;
  70. /**
  71. * Limits the amount of stack trace lines that will be recorded in the stacktrace.
  72. */
  73. stackTraceLimit?: number;
  74. /**
  75. * Limits the size in bytes of the job's data payload (as a JSON serialized string).
  76. */
  77. sizeLimit?: number;
  78. }
  79. export interface BaseJobOptions extends DefaultJobOptions {
  80. /**
  81. * Repeat this job, for example based on a `cron` schedule.
  82. */
  83. repeat?: RepeatOptions;
  84. /**
  85. * Internal property used by repeatable jobs to save base repeat job key.
  86. */
  87. repeatJobKey?: string;
  88. /**
  89. * Override the job ID - by default, the job ID is a unique
  90. * integer, but you can use this setting to override it.
  91. * If you use this option, it is up to you to ensure the
  92. * jobId is unique. If you attempt to add a job with an id that
  93. * already exists, it will not be added.
  94. */
  95. jobId?: string;
  96. /**
  97. * Parent options
  98. */
  99. parent?: ParentOptions;
  100. /**
  101. * Internal property used by repeatable jobs.
  102. */
  103. prevMillis?: number;
  104. }