Events

Events are things which can be triggered by the indexer at various times. Because we don't want to have to wait for out mime type scan to complete and are not bothered when it completes we may as well make an event which can run at a convienient time.

Other examples of events are:

Thumbnail Generation

Full text indexing

RDF generation

These are all things which can be queued up so as not to slow the deposit process.

The last thing to note about events is that the indexer obeys the eprint edit-lock, so if someone has the resource locked, the events won't happen yet.

The indexer trys to execute queued events every 30 seconds and you can view the status of events and the indexer via the "status" button under the "System Tools" tab of the admin interface.

ScanFile event

An Event is just another type of plug-in thus you create it in a the archives cfg/plugins/EPrints/Plugin/Event/ folder.

Below is an event with a single sub which performs the needed operation, all this needs to be parsed is a file_id.

Triggers

Triggers in EPrints and like message queues, you register a function which is called when a trigger point is hit.

There are lots of triggers in EPrints which are defined in the EPrints/Const.pm file however not all of them have trigger points at the time of writing.

Ideally we would want to use the EP_TRIGGER_FILES_MODIFIED as our trigger, however this is one of the ones which currently has no trigger point. So instead we are going to register our code against the EP_TRIGGER_AFTER_COMMIT on the file dataset only.

There are two types of trigger:

Repository Triggers: General purpose triggers which should always be called with the same params and types.

Dataset Triggers: Similar to repository triggers except they operate on a single dataset which changes depending on the trigger point.

We are thus going to register our trigger against the file dataset using a dataset trigger.

Our Dataset Trigger

Triggers are registered in the repository config on load, thus the code can sit in our config file under cfg/cfg.d/.

Finish and test

Once again we can package up these files and package install them, beware of testing the dataset stuff on the database and leaving the fields there after you remove you file for packaging.

To test this is all working we can look in the indexer status to ensure the event it getting queued and not failing, hopefully on this page you won't see anything.

To see the resultant values which are written to the dataset you will need to either print them back out in the file citation, or hack your way into the mysql database for your repository and see if it is putting the values in the file table.

select fileid,filename,file_cmd_mime from file where datasetid="document" order by fileid desc limit 10;