dox_queue 3.2.1
dox_queue: ^3.2.1 copied to clipboard
Background jobs for the Dox framework: Redis and sync drivers, retries, delays, chains, batches and workers.
3.2.1 #
- Fix: a bad
REDIS_PORTno longer puts its value in the error. Before, the error showed the value, which can be a secret. Now the error is the fixed textREDIS_PORT must be a number. - Fix: the wrong-scheme error of a bad
REDIS_URLno longer shows any part of the URL. Before, it showed the text before the first:. For a URL with no scheme, that text can be a user name or a secret token. Now the error is the fixed textREDIS_URL must start with redis:// or rediss://. - Fix: a bad
REDIS_URLno longer puts the Redis password in the error. Before, a bad port or a wrong scheme gave an error with the full URL, so the password went to the logs. Now the error shows the URL with the user and password hidden. - Fix: the queue worker (
QueueWorker,bin/queue.dart work) now checksAPP_KEYat start, like the web server does. A short or public sample key stops the worker in production and only logs a warning in development, local and test.
3.2.0 #
- New
dox queue:install [--driver=database|redis|sync], run bydox add queue. It writeslib/config/queue.dart, the provider,bin/queue.dartand a sample job, adds theREDIS_*keys forredis, and fordatabaseadds dox_queue_database and thecreate_queue_tablesmigration. It never overwrites a file. dox_queue now depends ondox_annotation. - Breaking: the builder that writes
lib/generated/jobs.g.dartmoved to dox_builder. So dox_queue no longer depends onanalyzer,build,dart_styleandglob. Use the dox_builder release that has the job builder, and runbuild_runneras before. The file and itsjobRegistrystay the same. If yourbuild.yamlnames the builderdox_queue:jobs, change it todox_builder:jobs. - Breaking: use dox_builder 3.2 or newer with this dox_queue. An older dox_builder has no job builder, so
jobs.g.dartis not made. Rundart pub upgradeto move both together. (dox_builder 3.2 with dox_queue 3.1 stopsbuild_runnerwith "outputs collide"; its CHANGELOG has thebuild.yamlfix.) A plain Dart app (no Dox) that had onlybuild_runnernow also needsdox_builderindev_dependencies:dart pub add dev:dox_builder. - New:
QueueConfig(inProcess:)is the new name ofworkInProcess, the same asScheduleConfig(inProcess:).workInProcessstill works (parameter and getter), but is deprecated. When both are given,inProcesswins. - Changed:
QueueProviderstarts the in-process worker (inProcess: true) inboot(), aftersetup()of every provider, not insetup(). So the other providers (eg. the mail jobs of dox_mailer) are ready before the first job runs. The worker has its own job store from the provider config.QueueWorker(bin/queue.dart) runsboot()of every provider too. Needs the dox_core release that runsDoxProvider.boot(). - Breaking: the scheduler process (
bin/schedule.dart) no longer starts an in-process queue worker. 3.1 did, because it ransetup()of every provider. The scheduler does not runboot(). Run a worker withinProcessin the web server, or withbin/queue.dart. - Breaking: code that runs the providers itself and calls only
setup()(a custom runner) no longer starts the in-process worker. Callboot()of every provider after theirsetup()too. Queue.pruneBatches()with no batch store gives a failed Future, not a throw.- Breaking: the
databasequeue driver (DatabaseQueueDriver) moved to the new packagedox_queue_database. Add the package and make your queue provider extend itsDatabaseQueueProviderin place ofQueueProvider.QueueConfig(driver: 'database')without it throws anArgumentErrorthat names the package. - Breaking:
QueueTablesand thedox queue:tablecommand moved todox_queue_database. The migration thatdox queue:tablewrites importspackage:dox_queue_database/dox_queue_database.dart. - Breaking: the batch store moved to
dox_queue_database.Queue.batch()needs it, also with the Redis driver. Without it,Queue.batch()throws aStateErrorthat says to adddox_queue_database. - Breaking:
afterCommitmoved todox_queue_database. Without it, a dispatch withafterCommiton throws aStateError. - Breaking: the queued mail classes (
SendQueuedMail,SendEncryptedQueuedMail,RedactedMailErrorandQueueMailQueue) moved todox_mailer. The saved job names staydox_queue:SendQueuedMailanddox_queue:SendEncryptedQueuedMail. - Breaking:
Queue.fake()no longer swaps the mail queue. A custom queue set withMail.useQueue()is not caught by it.Mail.queue()with the default queue is still caught. - Breaking: dox_queue no longer depends on
dox_mailerordox_orm. It depends ondox_coreandioredisonly. The unreleasedschedule.job()is gone too, with thedox_schedulerdependency: uses.call('send-report', () => SendReport().dispatch()). - The repo is now a pub workspace with two packages,
dox_queueanddox_queue_database. They share one version and onev<version>tag. - New
Queue.extend(name, factory): add a queue driver with aQueueDriverFactory. - New
Queue.useBatches(BatchRepository? repository): set the batch store. - New
Queue.useTransactions(QueueTransactions? transactions): set theafterCommitsupport. - New
JobRegistry.addBuiltIn(JobCodec codec): a package adds its own built-in jobs (dox_mailer uses it). Batchhas a public constructor and a publicoptionsfield, for aBatchRepository.- New
Queue.decryptData(data, job)decrypts job data.QueueLogandfreeUniqueLockOfare exported for driver authors. - Fix: with
afterCommit, a transaction on a named dox_orm connection no longer counts as open. Only a transaction of the default connection defers the job (it is the one the job waits for). This now lives in dox_queue_database. - Fix: the worker did not stop on SIGTERM when Redis was down. A pop waited for a job that never came, so it needed
kill -9. NowWorker.run()ends onstop()even when a pop is stuck, sobin/queue.dartstops on SIGTERM. A pop that is already running gets a short grace (5 seconds) to return its job, and that job then runs. The grace applies to every stop: SIGTERM, SIGINT,restart,--max-time,--max-jobsand--memory. A job that a pop returns after the grace is released back to the queue at once, with the attempt the pop counted taken back. The job did not run, so it runs normally later. - New opt-in
afterCommitfor chains and batches:Queue.chain(jobs).dispatch(afterCommit: true)andQueue.batch(jobs).dispatch(afterCommit: true). The same rule as for one job: inside a transaction of the default dox_orm connection, the batch row is saved and the jobs are pushed only after the commit, and a rollback drops it all. Outside a transaction it happens at once. Null takesQueueConfig.afterCommit, andfalsewins over it. Before the commit, the returnedBatchis not saved yet (it has the id and the counts of a new batch). With thesyncdriver the whole chain runs after the commit, in order (before, each job of it waited on its own), and gives a new id before the commit.Queue.fake()keeps the chain or batch atdispatch(). Needs no schema change. - New opt-in batch events:
Queue.batchDispatched(),Queue.batchProgress(),Queue.batchFinished(),Queue.batchFailed()andQueue.batchCancelled(). They use the queue events: aQueueListenergets aQueueEventwith the newtypevaluesbatchDispatched,batchProgress,batchFinished,batchFailedandbatchCancelled, and the new fieldbatch(the batch after the step:id,nameand the counts).batchFailedalso has theerror.batchDispatchedfires in the process that calleddispatch(), before the jobs are pushed. The others fire in the process that counted the step (the worker, or the dispatcher with thesyncdriver). Each fires once per step, also with many workers.Batch.cancel()now cancels with one atomic step, sobatchCancelledfires once.Queue.fake()fires no batch events.Queue.forgetListeners()removes them too. - New opt-in chains inside a batch:
Queue.batch(jobs).chain(<DoxJob>[A(), B()]). The jobs of the chain run one after the other. The batch counts the chain as one job: done when its last job is done, failed when one of its jobs fails for good (the rest of the chain is dropped, and the batch failure rules count, alsoallowFailures()). A skippedShouldBeUniquefirst job takes the chain out of the counts. A skipped later job, or a next job that can not be read, fails the chain. Works with every driver.Queue.fake()keeps the chains in the newPendingBatch.chains, and the newassertBatchedChain([A, B])checks them.Batch.add()still takes jobs only. A batch with no chain works as before. - Ships an AI agent skill (dox-queue-guide). Install it in your app with
dart run skills@ get. - New opt-in job batches, like Laravel
Bus::batch():Queue.batch(jobs).name(name).allowFailures().before(job).progress(job).then(job).catchError(job).whenComplete(job).dispatch(queue:, connection:)returns aBatch(id,name,totalJobs,pendingJobs,failedJobs,processedJobs,progress,finished,cancelled,cancel(),add(jobs)).Queue.findBatch(id)reads a batch again.whenCompleteis Laravelfinally(a reserved word in Dart). The callbacks are jobs, not functions (a function can not be saved). They run once, in the process where the step happened, likedispatchSync(). The new opt-in mixinBatchablegives a jobbatchIdandbatch(), so it can skip its work when the batch was cancelled. The first failed job cancels the batch unlessallowFailures(). Batches are saved in a newjob_batchestable of the dox_orm connection ofQueueConfig.connection, also with the Redis driver. Make it with the newQueueTables.upBatches(schema)(anddownBatches).dox queue:tablenow adds these lines. An app that ran the older migration adds them in a new migration. An app with no batches needs no table. Each count change is one atomic statement (UPDATE ... RETURNINGon SQLite and Postgres, a transaction with a row lock on MySQL and MariaDB), so with many workers each callback runs once. The batch id is saved in a new optional payload fieldbatch. A skippedShouldBeUniquejob is taken out oftotalJobsandpendingJobswith noprogresscall (thenandwhenCompleterun when it was the last open job). A failed job retried withqueue:retryis marked in a new optional payload fieldbatchFailed: when it fails again it is not counted again, and when it is donependingJobsandfailedJobsboth go down.add()throws aStateErrorfor a finished, cancelled or deleted batch and pushes nothing. An empty batch throws anArgumentError. A push that throws indispatch()oradd()takes the jobs that were not pushed out of the counts, cancels the batch and throws the error; the jobs pushed before still run and still fire the callbacks. The batch is marked finished beforethenandwhenCompleterun, so a lateadd()throws. The counts are at-least-once: a job that runs twice can be counted twice.failedJobsnever goes below 0. Without the table,dispatch()throws aStateErrorthat namesQueueTables.upBatches(). Thesyncdriver runs the jobs atdispatch()and counts them (a failed job does not throw).Queue.fake()keeps the batches in the newQueueFake.batches, withassertBatched([test])andassertBatchCount(n). New commandprune-batches --hours=Nofbin/queue.dart(andQueue.pruneBatches(before, unfinishedBefore:)) deletes old finished batches, and with--unfinished=Nalso old batches that never finished. - New opt-in job chains, like Laravel
Bus::chain():Queue.chain(jobs).catchError(job).dispatch(queue:, connection:, delay:). The jobs run one after the other. The next job is pushed only when the one before it is done (also afterdelete()or a middleware that skips it). A release or a retry keeps the chain. When a job fails for good, the rest is dropped and the catch job runs. The rest of the chain is saved in new optional payload fieldschainandchainCatch, so it works across worker processes and restarts. Old payloads still read, and a payload without a chain is the same as before. The catch handler is a job, not a function (a function can not be saved). It runs once in the worker where the job failed, likedispatchSync(). With the new opt-in mixinCatchesErrorit reads the error incaughtError. AShouldBeUniquejob of the chain that is skipped, or a next job that can not be read, stops the chain and runs the catch job.ShouldBeEncryptedjobs stay encrypted inside the chain. Thesyncdriver runs the jobs now, one after the other.Queue.fake()keeps the chains in the newQueueFake.chains, andassertChained([A, B])checks them. The next job fires thequeuedevent like any dispatch. The worker pushes the next job before it deletes the job that is done, like Laravel. When that push throws, the try counts as failed, so the job is retried (it runs again), and when no try is left it fails and the catch job runs. A crash between the push and the delete can run the next job twice. A failed push counts as a failed try of a job whosehandle()worked (exceptionOccurred, and at the last tryfailed()and thefailedevent), so give chain jobs more than one try. The unique lock of the job is freed before the push, so a next job with the same unique id is not skipped. - New queue events, like Laravel:
Queue.queued(),Queue.before()(processing),Queue.after()(processed),Queue.released(),Queue.exceptionOccurred()(the job will be tried again),Queue.failing()(failed for good),Queue.looping()andQueue.stopping(). Each takes aQueueListener, a function that gets aQueueEvent(type, job, job name, id, queue, try number, error, delay). Each event fires once per step. Listeners are per isolate, so add them where the app starts. A listener that throws is logged, and never stops the worker or the dispatch.Queue.forgetListeners()removes them. Thesyncdriver,dispatchSync()andQueue.fake()fire no events. dox_core has no event system, so these are static hooks. - New opt-in unique jobs, like Laravel:
with ShouldBeUnique(anduniqueId,uniqueFor) andwith ShouldBeUniqueUntilProcessing. While a job with the same name anduniqueIdis on the queue,dispatch()pushes nothing and returns an empty id (''), so the return type staysFuture<String>. The worker frees the lock when the job is done, deleted or failed for good (ShouldBeUniqueUntilProcessing: when the job starts). A release or a retry keeps it.uniqueForends the lock after a time (null: no end). The lock is a lock of the default cache store, owned by the job id, so a worker never frees the lock of a newer job. The web app and the workers must use the same cache store (eg.redis). WithafterCommitinside a transaction, the lock is taken at the commit. Thesyncdriver frees the lock after the job ran.dispatchSync()does not use the lock.Queue.fake()keeps its own locks, needs no cache, andclear()frees them. The payload of a unique job saves the lock name in a new optional fieldunique(JobPayload.unique). So the worker frees the lock also when the job class can not be read, andclearfrees the locks of the jobs it deletes (it reads the deleted jobs once: Redis in pages of 1000, the database with oneLIKEquery). Old payloads have no such field and still read. The payload of a job that is not unique does not change.queue:retrydoes not take the lock. A crash of a worker or ofclearleaves the lock: setuniqueFor. A broken payload is logged and skipped byclear. Fix (Redis): a job released by a worker afterclear(or after its reservation ran out and another worker took it) no longer comes back on the queue. - New job middleware
RateLimited(key, max, per),WithoutOverlapping(key, {releaseAfter, expireAfter})andThrottlesExceptions(key, {maxAttempts, decay, retryAfter}), like Laravel.RateLimitedruns at mostmaxjobs of a key per window, the others go back on the queue until the window ends.WithoutOverlappingruns one job of a key at a time; the others go back afterreleaseAfter(null: they are dropped).ThrottlesExceptionsstops jobs of a key fordecayaftermaxAttemptserrors. They keep their counts and locks in the default cache store (Cache()), so every worker that uses the same store (eg.redis) shares them. A release counts as a try: give such jobs moretriesor aretryUntil. Unlike Laravel,WithoutOverlappingdoes not add the class name to its lock.ThrottlesExceptionskeeps afail()ordelete()of the job when it then throws. WithdispatchSync(),dispatchAfterResponse()and thesyncdriver there is no queue: when a middleware releases the job,handle()does not run and a warning is logged. - New opt-in job middleware, like Laravel:
class MyJob extends DoxJob with HasMiddlewareandList<JobMiddleware> get middleware. EachJobMiddlewarehasFuture<void> handle(DoxJob job, JobNext next)and wrapshandle()of the job. The first one runs first. A middleware can skip the job (it does not callnext: the job is done) or put it back withrelease(job, delay)(it counts as a try, likerelease()ofInteractsWithQueue). The worker, thesyncdriver anddispatchSync()use them. It is a mixin, so jobs without it work as before, also when they have their ownmiddlewaremember. - New opt-in
QueueConfig(failedAtTimestamp: true)andQueueTables.up(schema, failedAtTimestamp: true):failed_jobs.failed_atis a timestamp column in UTC, like Laravel, not a big integer of unix time in milliseconds. The setting counts per queue connection.FailedJob.failedAtis the sameDateTimewith both types. Thedatabasedriver reads the column type once, on its first use offailed_jobs, and throws aStateErrorwhen the setting and the column do not match, so no wrong value is written. When the type can not be read, it is read again on the next call: with the setting off the call goes on after a warning, with the setting on it throws. On MySQL and MariaDB the time is written withFROM_UNIXTIME()and read withUNIX_TIMESTAMP(), so the session time zone does not change it. The docs have the SQL to change a table with the integer column on SQLite, Postgres and MySQL. With the setting off, the table and the values are as before. The Redis driver does not use it. - New opt-in
dispatch(afterCommit: true)(also ondispatchIf(),dispatchUnless()andQueue.dispatch()) andQueueConfig(afterCommit: true)for every dispatch, like LaravelafterCommit(). Inside a transaction of the default dox_orm connection, the job is pushed only after the outermost transaction commits. A rollback drops it. Outside a transaction it is pushed at once.afterCommit: falseon one dispatch wins over the setting, like LaravelbeforeCommit().dispatch()returns the job id at once. A job that is not in the registry, or data that is not JSON, still throws atdispatch(). Thesyncdriver runs the job after the commit.dispatchSync()anddispatchAfterResponse()do not change.Queue.fake()keeps the job atdispatch(), like Laravel. With nothing new used, dispatch works as before. Needs the next dox_orm (withQueryBuilder.afterCommit()): the dox_orm constraint must go up to that version at release. - New opt-in mixin
InteractsWithQueue, like Laravel:class MyJob extends DoxJob with InteractsWithQueue. Insidehandle()the job can callattempts(),release(delay),fail(error)anddelete(). The worker does the call whenhandle()ends:release()puts the job back on its queue (it counts as a try, so settriesabove 1),fail()fails it at once and runsfailed(),delete()deletes it with nofailed(). The last call wins, and a call wins over an error thrown after it (also aTimeoutExceptionof the job itself, and indispatchSync()afail()call gives its error tofailed(), while the thrown error still reaches the caller). When the worker timeout fires, the call is dropped and the timeout rules count. Outside a worker (dispatchSync(),dispatchAfterResponse(), thesyncdriver)attempts()is 1,release()anddelete()do nothing, andfail()only runsfailed(). Jobs without the mixin work as before, also when they have their own members of these names. - New opt-in
QueueConfig(serializeSync: true): thesyncdriver saves the job and reads it back before it runs, like a worker gets it. So a job that is not in the registry, or a field that is not JSON, throws in tests. The default runs the job object as it is. - New opt-in queue connections:
QueueConfig(connections: {'database': QueueConfig(driver: 'database')}),dispatch(connection: 'database')(also ondispatchIf(),dispatchUnless()andQueue.dispatch()),Queue.driverOf(name)and the--connection=NAMEflag for every command ofbin/queue.dart. The config itself is the main connection, used when no connection is named.Queue.fake()keeps the name inPushedJob.connection. A config with noconnectionsworks as before. - New:
failed_jobshas a nullableconnectioncolumn. A failed job of a named connection saves the name there. The main connection leaves it NULL. Afailed_jobstable without the column keeps working: the driver checks for the column once and then leaves it out. Add it withtable.string('connection').nullable()in a new migration, then restart the workers (they check for the column once). Queue.fake()did not keep the jobs ofdispatchSync()anddispatchAfterResponse(), so a test could not check them. Now the fake keeps them indispatchedSyncanddispatchedAfterResponse. The jobs still run, as before. They are not inpushed, soassertPushed()and the other checks work as before.clear()also empties the two new lists.- New:
dispatchAfterResponse()runs a job after the response is sent, like Laravel. The client does not wait for it. The job runs in the same process, likedispatchSync(). It does not go on the queue, so it returns nothing (no job id) and has no retry. Outside a request it runs soon. An error goes to the exception handler, never to the client.QueueProvidernow callsAfterResponse.enable()of dox_core for it. Needs dox_core withAfterResponse. SendQueuedMailandSendEncryptedQueuedMailare now exported. A test withQueue.fake()can check a queued email withqueue.assertPushed<SendQueuedMail>().- Docs:
clearalso deletes the reserved (running) jobs of the queue, not only the waiting and delayed ones. - Note for custom drivers: a driver that
extends QueueDrivergetsclear()andpruneFailed()(they throw anUnsupportedError). A driver thatimplements QueueDrivergets no code from it, so it must addclear()andpruneFailed()itself, or it does not compile. Queue.retryUntilOf()now logs a warning (with the error type) when it can not read the job. Before, it hid every error.JobPayload.retried()takes the newretryUntilas a parameter. The built-in drivers read it with the newQueue.retriedPayload(), soJobPayloaddoes not read the globalQueue.configany more. A custom driver that callsretried()should useQueue.retriedPayload(), or the retried job has noretryUntil.
3.1.0 #
- New opt-in job settings:
retryUntil(retry until a time, nottriestimes),maxExceptions(fail after this many tries that threw) andfailOnTimeout(fail at once on a timeout). Jobs without them work as before.retryUntilis read once at dispatch and saved with the job. Rows saved before this change are read as jobs with noretryUntil.queue:retrygives a failed job a fresh start: the tries and the exceptions count go back to 0, andretryUntilis read again from the job class. - New:
dispatch(delayUntil: DateTime)waits until a time.delay: Durationstill works. Give one of them, not both. - New:
dispatchIf(condition)anddispatchUnless(condition). They return the job id, or null when the job was not dispatched. - New worker flags:
--backoff=SECONDS[,SECONDS...](the retry wait of a job with nobackoff),--max-jobs=N,--max-time=SECONDSand--memory=MB(stop the worker after the running jobs). All are off by default. - New commands of
bin/queue.dart:clear [queue]deletes the jobs of a queue.restartmakes the running workers stop after their current jobs (it writes a time to the app cache, so the workers must share one cache store).prune-failed --hours=Ndeletes failed jobs older than N hours (default 24). - New
QueueDriver.clear()andQueueDriver.pruneFailed(). The Redis and database drivers have them. A custom driver that does not override them throws anUnsupportedError. QueueDriver.release()now also savesjob.payload, so the worker can keep the exception count. A custom driver should save it too.- Fix: the
QueueFakemessages said "a UnusedJob". Now only "Uni" and "U" + one consonant (not "n") + vowel give "a", so it says "an UnusedJob" and still "a UniJob". - Fix: when
Mail.fake()was on beforeQueue.fake(),Queue.restore()lost a queue set withMail.useQueue(). NowQueue.fake()does not touch the mail queue whileMail.fake()is on. - Fix: the
QueueFakecheck messages had bad grammar, like "a AllTypesJob" and "1 times". Now they say "an AllTypesJob" and "1 time". A name that starts with a "you" sound (likeUserJoborEuJob) gets "a". - Fix:
Queue.restore()did not undo theMail.useQueue()call ofQueue.fake(). With noQueue.configure(),Mail.queue()still found a queue after the test. Nowrestore()puts back the queue it had beforeQueue.fake()(also one fromMail.useQueue()). If it had none: no queue, or this queue whenQueue.configure()was called. - New:
Queue.fake()for tests. It keeps every dispatched job in aQueueFakeand does not run or save them. Check them withassertPushed<T>([test]),assertPushedTimes<T>(n),assertNotPushed<T>()andassertNothingPushed(). Read them withpushed(each has the job, the queue name and the delay) orjobsOf<T>(). It also catchesMail.queue()andMail.later().dispatchSync()still runs the job.Queue.restore()stops the fake. - Fix: with
Mail.queue(message, encrypt: true), a send error could name the recipient (eg. an SMTP reply550 <ann@example.com>: mailbox unavailable). The worker wrote that error to its log and to the failed jobs in plain text. Now the encrypted mail job throws aRedactedMailError. Its text has only the error type and the SMTP or HTTP code. The full error text, with the answer of the server, is encrypted with the app key (at most the first 64K characters, counted in UTF-16 code units). Read it withRedactedMailError.decrypt(job.error). When the error can not be encrypted, only the type and the code are kept. Mail jobs withoutencryptkeep the full error, as before. - New:
dox queue:tablewrites a migration for thejobsandfailed_jobstables indb/migration. It callsQueueTables.upandQueueTables.down. It does not overwrite: when acreate_queue_tablesmigration is already there, it prints so and exits with code 1. It is a package command (dox: commands:in pubspec.yaml), so it needs adoxCLI that finds package commands. - Needs dox_core with
package:dox_core/command.dart. - New: a built-in job for
Mail.queue()andMail.later()of dox_mailer.Queue.configure()turns it on. Apps do not add it tolib/generated/jobs.g.dart: everyJobRegistryfinds the built-in jobs (JobRegistry.builtIn) after its own jobs. Withencrypt: true, the mail is saved like aShouldBeEncryptedjob. - Now depends on dox_mailer.
- Deploy the queue worker together with the web app. An old worker does not know the new mail job, so it fails the queued emails.
- Fix (opt-in): a job that timed out keeps running, and its retry could run at the same time. The new worker flag
--timeout-grace=SECONDS(WorkerOptions.timeoutGrace) makes the worker wait for the old run before the next try. The default does not change. For the in-process worker, useQueueConfig(workerTimeoutGrace: ...). - New opt-in
QueueConfig.redisFromEnv(): reads the Redis server fromREDIS_URL, or fromREDIS_HOST,REDIS_PORT,REDIS_USERNAME,REDIS_PASSWORDandREDIS_TLS. Use it asQueueConfig(redis: QueueConfig.redisFromEnv()). Without it, the default is still localhost:6379. - Opt-in
ShouldBeEncryptedjob mixin: the job data is saved encrypted with the app key (AES-GCM of dox_core). Jobs without it are saved as before. - Needs dox_core 3.1.0 or newer.
3.0.0 #
- The first stable release.
3.0.0-rc.1 #
- Uses the
Loggerthatdox_corenow exports, so it needs dox_core 3.0.0-rc.1. - Fix: a
Workerstarted withoutDox().initialize()crashed with aLateInitializationErrorwhen it logged. Now it logs to stdout, and errors to stderr.
3.0.0-alpha.5 #
- Works with ioredis 3.0.0, so it works with dox_core 3.0.0-alpha.16 and newer.
3.0.0-alpha.4 #
QueueProvider(was a DoxService): extend it in your app,shutdown()is optional.
3.0.0-alpha.3 #
- A job with no fields no longer gives an "unused variable" warning in
lib/generated/jobs.g.dart.
3.0.0-alpha.2 #
- The builder now writes the job registry to
lib/generated/jobs.g.dart. Import it from there.
3.0.0-alpha.1 #
- First version.
- Jobs:
@Job()andDoxJobwithtries,backoff,timeout,queueand afailed()hook. - A builder writes
lib/jobs.g.dart: it saves and loads the constructor parameters of each job, with no mirrors. dispatch(),dispatchSync()andQueue.dispatch()withdelayandqueue.- Drivers:
sync,database(Postgres, MySQL, MariaDB, SQLite) andredis. QueueServicesets up the queue in every isolate.workInProcessruns a worker in the web server.QueueWorkerforbin/queue.dart:work,failed,retry,forgetandflush.- Retries with backoff, failed jobs, timeouts, delayed jobs, crashed worker recovery and graceful stop.
QueueTablesmakes thejobsandfailed_jobstables.