It would be handy to have background jobs just call a simple method for: * Setting the job as started * Updating the progress * Setting as finished
Created attachment 132247 [details] [review] Bug 30360: Add helper methods to Koha::BackgroundJobs This patch adds some helper methods to ease writing background jobs, and also making it more consistent/solid. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/BackgroundJob.t => SUCCESS: Tests pass. The methods have the expected behaviour. 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
What about retry?
(In reply to Jonathan Druart from comment #2) > What about retry? Yeah, I thought about it, and like the idea. It would involve (maybe) a new status which by the way we should move into an ENUM. I left it out only because I believe we need to also think of 'all or nothing' vs 'partial success' tasks. We should support both, in my opinion.
Created attachment 132952 [details] [review] Bug 30360: Add methods for dealing with the JSON payload This patch adds high-level methods to handle the JSON payload (de)serialization as needed. This allows devs implementing background jobs to abstract themselves from the internals of the jobs handling. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/BackgroundJob.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 132953 [details] [review] Bug 30360: Make UpdateElasticIndex use the helper methods Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Looking forward to this one :)
Created attachment 134414 [details] [review] Bug 30360: Add helper methods to Koha::BackgroundJobs This patch adds some helper methods to ease writing background jobs, and also making it more consistent/solid. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/BackgroundJob.t => SUCCESS: Tests pass. The methods have the expected behaviour. 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 134415 [details] [review] Bug 30360: Add methods for dealing with the JSON payload This patch adds high-level methods to handle the JSON payload (de)serialization as needed. This allows devs implementing background jobs to abstract themselves from the internals of the jobs handling. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/BackgroundJob.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 134416 [details] [review] Bug 30360: Make UpdateElasticIndex use the helper methods Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 134417 [details] [review] Bug 30360: Add helper methods to Koha::BackgroundJobs This patch adds some helper methods to ease writing background jobs, and also making it more consistent/solid. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/BackgroundJob.t => SUCCESS: Tests pass. The methods have the expected behaviour. 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com>
Created attachment 134418 [details] [review] Bug 30360: Add methods for dealing with the JSON payload This patch adds high-level methods to handle the JSON payload (de)serialization as needed. This allows devs implementing background jobs to abstract themselves from the internals of the jobs handling. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/BackgroundJob.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com>
Created attachment 134419 [details] [review] Bug 30360: Make UpdateElasticIndex use the helper methods Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com>
(In reply to David Nind from comment #11) > > Signed-off-by: David Nind <david@davidnind.com> Thanks, David!!
Created attachment 134631 [details] [review] Bug 30360: Add helper methods to Koha::BackgroundJobs This patch adds some helper methods to ease writing background jobs, and also making it more consistent/solid. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/BackgroundJob.t => SUCCESS: Tests pass. The methods have the expected behaviour. 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 134632 [details] [review] Bug 30360: Add methods for dealing with the JSON payload This patch adds high-level methods to handle the JSON payload (de)serialization as needed. This allows devs implementing background jobs to abstract themselves from the internals of the jobs handling. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/BackgroundJob.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 134633 [details] [review] Bug 30360: Make UpdateElasticIndex use the helper methods Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Ack, I actually QA'd this soon after David's SO and then promptly got interrupted before uploading the patches and changing the status. It's a really solid improvement and does no harm so I'm marking it as a 22.05 candidate.
Pushed for 22.05, thanks to everyone involved :).. dependency for trivial bug 30362