Worker:-Background-jobs-using-Gearman

The embedded Erfurt library contains a background worker implementation using Gearman. This means: OntoWiki and its extensions can handle expensive tasks in the background by calling a job for execution which were registered on the server beforehand.

Now here is how it works and how you can use it:

Server

To make use of Gearman as worker background, you need to install the Gearman service on the server.

Client script

Usage in OntoWiki / Erfurt

Classes in Erfurt

Worker_Registry

This class will be started by the server side shell script to start the job server.

It triggers the event onAnnounceWorker and will allow OntoWiki / Erfurt components to state their worker jobs.
These will be stored within the registry as a later input for the worker backend.

Worker_Backend

This class is wrapper for the Gearman worker, which runs server side.
It knows the worker registry and add the registered jobs to the Gearman server.
Afterwards the server side worker script will set the backend and Gearman server to listen mode.

While this is the empty engine for handling job calls, you will now also need jobs classes to register.

Worker_Job_Interface

Every job class will implement the interface.
At the moment you will need to implement the run method by your needs.
So every job class only has one public method, which will be called automatically.

Worker_Job_Container

This class is used to store registerable worker jobs within the worker registry.
You do not need to use this class at all.

Configuration

Configure in either OntoWiki/application/config/default.ini or OntoWiki/libraries/Erfurt/library/Erfurt/config/default.ini: