As well as simple "every" and "when" expressions, advanced users may
want to use arbitrary OCaml expressions, functions, etc in the jobs
script. These are useful for factoring common code or strings, for
-setting the initial values of variables, or for defining cleanup
+setting the initial values of variables, or for defining pre and post
functions.
A simple example of an OCaml expression is:
Whentools.set_variable "name" "Richard";
Whentools.set_variable_int "counter" 0
-=head3 CLEANUP FUNCTIONS
+=head3 POST FUNCTIONS
After a job runs, you can control what happens to its output by
-writing a cleanup function. To write a cleanup function you have to
-name the job (ie. have an explicit C<job> statement). Put C<cleanup ...>
+writing a C<post> function. To write a post function you have to
+name the job (ie. have an explicit C<job> statement). Put C<post ...>
after the job name like this:
job "poll source"
- cleanup (Whentools.mailto "you@example.com")
+ post (Whentools.mailto "you@example.com")
every 10 seconds :
<<
# ...
>>
-A number of cleanup functions are available in the library; see below.
+A number of post functions are available in the library; see below.
-You can also write your own cleanup functions (in OCaml). The
+You can also write your own post functions (in OCaml). The
function is passed one argument which is a C<Whentools.result> struct,
defined below.
Here are some examples of using the mailto function:
job "ex.1"
- cleanup (Whentools.mailto "you@example.com")
+ post (Whentools.mailto "you@example.com")
every 10 seconds :
<<
# do something
>>
job "ex.2"
- cleanup (Whentools.mailto ~only_on_failure:true
- "you@example.com")
+ post (Whentools.mailto ~only_on_failure:true
+ "you@example.com")
every 10 seconds :
<<
# do something
let to_addr = "you@example.com"
job "ex.3"
- cleanup (Whentools.mailto ~from to_addr)
+ post (Whentools.mailto ~from to_addr)
every 10 seconds :
<<
# do something
=item B<Whentools.result>
-This structure is passed to cleanup functions. It has the following
+This structure is passed to post functions. It has the following
fields:
type result = {