Let us start with a very simple example of a user rule:

firstrule.r

MyFirstRule { writeLine("stdout", "Hello world!"); } OUTPUT ruleExecOut

This rule can be run by a normal user irule -F firstrule.r and produces following output:

irule -F demo/firstrule.r Hello world!

Please note that the file containing the rule can be created on a local host and irule will submit it to a remote iRODS host for execution. It is hard to say that the rule presented contains any kind of workflow but we had to start somewhere.

An example of a workflow defined by a user would be a rule that retrieves a list of files from a given collection and calculates a checksum for each of them. Translated into iRODS rules the workflow would look like:

listAndCheck.r

myTestRule { acGetIcatResults(*Action,*Condition,*B); foreach ( *B ) { msiDataObjChksum(*B, *Operation, *C); msiGetValByKey(*B, "DATA_NAME", *D); writeLine("stdout", "Checksum of *D is *C") } } INPUT *Action="list",*Condition= "COLL_NAME = '/tempZone/home/rods'", *Operation="verifyChksum" OUTPUT ruleExecOut

Again the rule can be started by irule -F listAndCheck.r and produces following output:

irule -F demo/listAndCheck.r Checksum of file.1 is 77720d1e7094c99ce65c12b7a043bb6c Checksum of master.tex is 8afa737f1d788a8a50d519464bd61c77

It is also possible to define rules that will be executed periodically:

periodic.r

myPeriodicRule { delay("<PLUSET>1m</PLUSET><EF>1m</EF>"){ msiCollRsync(*srcColl,*destColl,*Resource,"IRODS_TO_IRODS",*Status); writeLine("serverLog","Synchronized collection *srcColl with collection *destColl"); } } INPUT *srcColl="/homeZone/original", *destColl="/destZone/copy",*Resource="demoResc" OUTPUT ruleExecOut

The rule has to be initially started like a normal rule with irule -F periodic.r. It will be executed after 1 minute (as defined in the <PLUSET> attribute) and then repeated every minute (as defined in <EF> attribute). The rule use synchronizes a collection from one zone /homeZone/original with a collection from other zone /destZone/copy. Each time the rule is called it will compare the content of the source collection with the destination and propagate the changes (if any detected).

You can get the information about the status of periodic rules running in the system by issuing iqstat command. The management (like removal of a periodic rule or changes in the frequency) can be done with iqdel and iqmod commands.

Due to the spacial limits of this document we are not able to describe all features of the rules in iRODS. The distribution contains a lot of examples which can be used to compose own rules. Please check the directory clients/icommands/test and its subdirectories for further information.

With high-probability the functionality you need to compose your own workflow is already present in iRODS. It is possible to print a list of micro-services available in the system (that can be used to compose own workflows). The list is printed by a following rule:

listEnabledMS.r

myTestRule { msiListEnabledMS(*Buf); writeKeyValPairs("stdout",*Buf,":"); } INPUT null OUTPUT ruleExecOut

If you are sure that a required functionality is not provided there is a possibility to define own micro-services, refer to Micro-services Section for further details. More information about iRODS rule language can be found in the project documentation.