Bug 30360 - Add helper methods to Koha::BackgroundJobs
Summary: Add helper methods to Koha::BackgroundJobs
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on: 27344
Blocks: 30734 30943 27341 30692
  Show dependency treegraph
 
Reported: 2022-03-25 13:30 UTC by Tomás Cohen Arazi
Modified: 2022-06-10 13:52 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00


Attachments
Bug 30360: Add helper methods to Koha::BackgroundJobs (6.88 KB, patch)
2022-03-25 14:55 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30360: Add methods for dealing with the JSON payload (2.57 KB, patch)
2022-04-04 22:34 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30360: Make UpdateElasticIndex use the helper methods (1.92 KB, patch)
2022-04-05 08:54 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30360: Add helper methods to Koha::BackgroundJobs (7.24 KB, patch)
2022-04-29 17:59 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30360: Add methods for dealing with the JSON payload (2.57 KB, patch)
2022-04-29 17:59 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30360: Make UpdateElasticIndex use the helper methods (1.92 KB, patch)
2022-04-29 17:59 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30360: Add helper methods to Koha::BackgroundJobs (7.29 KB, patch)
2022-04-29 18:05 UTC, David Nind
Details | Diff | Splinter Review
Bug 30360: Add methods for dealing with the JSON payload (2.62 KB, patch)
2022-04-29 18:06 UTC, David Nind
Details | Diff | Splinter Review
Bug 30360: Make UpdateElasticIndex use the helper methods (1.97 KB, patch)
2022-04-29 18:06 UTC, David Nind
Details | Diff | Splinter Review
Bug 30360: Add helper methods to Koha::BackgroundJobs (7.35 KB, patch)
2022-05-05 10:54 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30360: Add methods for dealing with the JSON payload (2.68 KB, patch)
2022-05-05 10:54 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30360: Make UpdateElasticIndex use the helper methods (2.03 KB, patch)
2022-05-05 10:54 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2022-03-25 13:30:19 UTC
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
Comment 1 Tomás Cohen Arazi 2022-03-25 14:55:02 UTC
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>
Comment 2 Jonathan Druart 2022-03-25 15:24:29 UTC
What about retry?
Comment 3 Tomás Cohen Arazi 2022-03-25 15:46:51 UTC
(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.
Comment 4 Tomás Cohen Arazi 2022-04-04 22:34:14 UTC
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>
Comment 5 Tomás Cohen Arazi 2022-04-05 08:54:37 UTC
Created attachment 132953 [details] [review]
Bug 30360: Make UpdateElasticIndex use the helper methods

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 6 Martin Renvoize 2022-04-11 16:48:05 UTC
Looking forward to this one :)
Comment 7 Tomás Cohen Arazi 2022-04-29 17:59:36 UTC
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>
Comment 8 Tomás Cohen Arazi 2022-04-29 17:59:41 UTC
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>
Comment 9 Tomás Cohen Arazi 2022-04-29 17:59:46 UTC
Created attachment 134416 [details] [review]
Bug 30360: Make UpdateElasticIndex use the helper methods

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 10 David Nind 2022-04-29 18:05:58 UTC
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>
Comment 11 David Nind 2022-04-29 18:06:04 UTC
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>
Comment 12 David Nind 2022-04-29 18:06:10 UTC
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>
Comment 13 Tomás Cohen Arazi 2022-05-02 12:09:38 UTC
(In reply to David Nind from comment #11)
>
> Signed-off-by: David Nind <david@davidnind.com>

Thanks, David!!
Comment 14 Martin Renvoize 2022-05-05 10:54:33 UTC
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>
Comment 15 Martin Renvoize 2022-05-05 10:54:37 UTC
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>
Comment 16 Martin Renvoize 2022-05-05 10:54:42 UTC
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>
Comment 17 Martin Renvoize 2022-05-05 10:56:55 UTC
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.
Comment 18 Martin Renvoize 2022-05-05 15:13:03 UTC
Pushed for 22.05, thanks to everyone involved :).. dependency for trivial bug 30362