Ticklers

From FreemedDeveloperWiki, the FreeMED developers' Wiki.

Jump to: navigation, search

Ticklers are autonomous events which can occur seperately from user sessions. They are meant to be called by an external cron job (or other regular event) via the XML-RPC mechanism. This gives FreeMED the abilities that it would have if it were a standalone daemon, instead of a web service.

Calling Ticklers

All ticklers on the system can be called with the XML-RPC call:

 FreeMED.Tickler.call ( [hash of parameters] )

This will return a CR-seperated list of messages, including any error messages which are generated by the ticklers.

Calling ticklers with the hash value interval will usually cause those which are interval-specific (such as every hour, et cetera) to not execute unless that value is specified correctly.

Possible interval values are:

  • hourly
  • weekly
  • monthly
  • yearly

Creating Ticklers

To create a tickler, either take an existing module, or create another one. In its constructor, add a handler for the tickler method. (Please note that the method doesn't have to be called tickler ... I just call it that in this example ... )

 $this->_SetHandler('Tickler', 'tickler');

Then create the actual method:

 function tickler ( $params = NULL ) {
     if ($params['interval'] == 'hourly') {
         // do some action here
         // ...
         // ...
         if ($is_done_without_error) {
             // Either use:
             print "MyModule tickler: Done without error!";
             // or
             return "MyModule tickler: Done without error!";
         }
     }
 } // end method tickler
Navigation