Worker Services
Worker services can be used by activity archiving drivers to offload heavy processing tasks from the Moodle server and enable the archiving system to perform complex transformations (e.g., PDF exports).
Tasks and Responsibilities
Offloading Heavy Processing Tasks
Performs off-loaded complex or heavy archiving tasks, e.g., web page to PDF rendering
Communication Interface
Communicates via the Moodle Webservice API
- Fully specified REST API via Moodle webservice API
- Webservice tokens are only valid for a single task and are automatically invalidated after task completion or timeout
- Webservice tokens only allow access to information that is required for the specific task
Deployment and Encapsulation
Worker services are deployed independent of Moodle. They should be shipped as self-contained Docker containers to allow easy deployment.
Status Reporting
Providing status information about current tasks as well as the worker service itself
Multiple Task Handling
Worker services must be able to handle multiple tasks in a queue. A worker service should allow multiple tasks to be processed in parallel.
Configurability
Allow configuration of the worker service, e.g., maximum number of parallel tasks, maximum task runtime, ...
Interfaced Components
Implementation
Worker service implementations do not have to follow strict rules and can be tailored to the respective activity archiving drivers that use them. However, they all should:
- Use the Moodle web services / external API
- Grant as least privileges as possible
- Grant privileges only for the exact time an activity archiving task is processed
- Be easy to deploy and configure
Examples
Quiz Archive Worker
An example of one such worker service is the Quiz Archive Worker Service that is used in conjunction with the Moodle Quiz Archiver Plugin.
The following diagram depicts the general architecture and information flow of the Moodle plugin and the corresponding worker service: