[Bug 30410] New: Add a way for plugins to register background tasks
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Bug ID: 30410 Summary: Add a way for plugins to register background tasks Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Plugin architecture Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org The idea is to have a way for plugins to define 'code' => 'class' mappings so the worker(s) can process tasks through plugin-provided classes. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |27783 CC| |martin.renvoize@ptfs-europe | |.com Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27783 [Bug 27783] Add handling for 'Queues' in the background job queue -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #1 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 132814 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=132814&action=edit Bug 30410: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 132815 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=132815&action=edit Bug 30410: Add a way for plugins to expose tasks they implement This patch implements a mechanism for plugins to tell Koha they implement background jobs, by returning a mapping ``` task => class ``` * _task_ is a string that will be used when queueing new tasks, to let the workers know which class to instantiate to launch the job (a.k.a. process). * _class_ is a string for a class name. For this to work, plugins need to include the 'namespace' attribute in their metadata. If they don't, they will be skipped when listing the valid _background jobs_. After this, high-level methods for letting plugins (easily) enqueue their tasks will be provided. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/BackgroundJob.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #3 from David Cook <dcook@prosentient.com.au> --- (In reply to Tomás Cohen Arazi from comment #2)
For this to work, plugins need to include the 'namespace' attribute in their metadata. If they don't, they will be skipped when listing the valid _background jobs_.
What's an example 'namespace' attribute? Is that used to prevent collisions with task names? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to David Cook from comment #3)
(In reply to Tomás Cohen Arazi from comment #2)
For this to work, plugins need to include the 'namespace' attribute in their metadata. If they don't, they will be skipped when listing the valid _background jobs_.
What's an example 'namespace' attribute? Is that used to prevent collisions with task names?
There's a clear example in the patches. Thanks -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #5 from David Cook <dcook@prosentient.com.au> --- (In reply to Tomás Cohen Arazi from comment #4)
There's a clear example in the patches. Thanks
My bad. I had already read the main patch but not the unit tests patch. I should've thought to look there, although I didn't think the example was that clear. I had to re-read it a few times. I suppose the plugin's "name" isn't usable since it's human-friendly and not machine friendly. A default method inherited from Koha::Plugins::Base that does something like this might be useful: sub namespace { my $namespace = lc(__PACKAGE__); $namespace =~ s/::/_/g return $namespace } I suppose free text and auto-generated both have their pros and cons... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #6 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to David Cook from comment #5)
(In reply to Tomás Cohen Arazi from comment #4)
There's a clear example in the patches. Thanks
I suppose the plugin's "name" isn't usable since it's human-friendly and not machine friendly.
I suppose free text and auto-generated both have their pros and cons...
The main problem is how big the column needs to be. I suggest you go try and sign the patches. Thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |kyle@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #132814|0 |1 is obsolete| | --- Comment #7 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 133180 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=133180&action=edit Bug 30410: Unit tests Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #132815|0 |1 is obsolete| | --- Comment #8 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 133181 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=133181&action=edit Bug 30410: Add a way for plugins to expose tasks they implement This patch implements a mechanism for plugins to tell Koha they implement background jobs, by returning a mapping ``` task => class ``` * _task_ is a string that will be used when queueing new tasks, to let the workers know which class to instantiate to launch the job (a.k.a. process). * _class_ is a string for a class name. For this to work, plugins need to include the 'namespace' attribute in their metadata. If they don't, they will be skipped when listing the valid _background jobs_. After this, high-level methods for letting plugins (easily) enqueue their tasks will be provided. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/BackgroundJob.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off --- Comment #9 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Nice clear code and gives us a great way to develop background tasks. All works as expected, Signing off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #133180|0 |1 is obsolete| | Attachment #133181|0 |1 is obsolete| | --- Comment #10 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 133192 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=133192&action=edit Bug 30410: Unit tests Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #11 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 133193 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=133193&action=edit Bug 30410: Add a way for plugins to expose tasks they implement This patch implements a mechanism for plugins to tell Koha they implement background jobs, by returning a mapping ``` task => class ``` * _task_ is a string that will be used when queueing new tasks, to let the workers know which class to instantiate to launch the job (a.k.a. process). * _class_ is a string for a class name. For this to work, plugins need to include the 'namespace' attribute in their metadata. If they don't, they will be skipped when listing the valid _background jobs_. After this, high-level methods for letting plugins (easily) enqueue their tasks will be provided. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/BackgroundJob.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #12 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 133194 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=133194&action=edit Bug 30410: (QA follow-up) Pluralise new methods, fix minor issues with language Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #13 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 133195 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=133195&action=edit Bug 30410: (QA follow-up) Only fetch plugins mapping once -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m --- Comment #14 from Fridolin Somers <fridolin.somers@biblibre.com> --- Please add to https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |22.05.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #15 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to master for 22.05, thanks to everybody involved 🦄 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Bug 30410 depends on bug 27783, which changed state. Bug 27783 Summary: Introduce background job queues https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27783 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #16 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 133386 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=133386&action=edit Bug 30410: (follow-up) Instantiate object in unit test This patch updates the unit test for the BackgroundJob->_derived_class() private method to instantiate a proper object to work on instead of calling the type_to_class_mapping method directly as non-object method. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #17 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to master : Bug 30410: (follow-up) Instantiate object in unit test -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |32561 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32561 [Bug 32561] background job worker is still running with all the modules in RAM -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #18 from David Cook <dcook@prosentient.com.au> --- Do we have any examples of this one? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #19 from Fridolin Somers <fridolin.somers@biblibre.com> --- Wiki page updated -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #20 from David Cook <dcook@prosentient.com.au> --- (In reply to Fridolin Somers from comment #19)
Wiki page updated
Thanks, Frido, although I don't see any example plugins? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #21 from Fridolin Somers <fridolin.somers@biblibre.com> --- I had a look but I really dont understand how to implement the hook. A pool request on kitchen sink is much welcomed. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #22 from David Cook <dcook@prosentient.com.au> --- (In reply to Fridolin Somers from comment #21)
I had a look but I really dont understand how to implement the hook. A pool request on kitchen sink is much welcomed.
Ok. I'm on leave the next 4 days, but I'll hopefully look at creating a plugin next week (if I can figure out how to!) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 --- Comment #23 from David Cook <dcook@prosentient.com.au> --- (In reply to Tomás Cohen Arazi from comment #4)
There's a clear example in the patches.
(In reply to Martin Renvoize from comment #9)
Nice clear code and gives us a great way to develop background tasks.
After nearly a year, I still can't understand this code and have no idea how to develop a plugin to use this hook. I'm keen to try it out, so I'll keep trying to figure it out, but it would be great to have some assistance either here or on the Koha Plugin Hooks wiki page... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30410 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |35070 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35070 [Bug 35070] Koha plugins implementing "background_jobs" hook can't provide view template -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org