Ability to define a job per single file for future maintainability of large jobs.
Quick Overview
job tst {
// slack-channel webhook url
channel = "https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxxx"
// which sql driver do you use?
driver = "mysql"
// data source name (connection string)
dsn = "root:root@tcp(127.0.0.1:3306)/dbname"
// the query this is a multiline example, you can just write the following
// query = "select * from users"
query = <<SQL
SELECT users.* FROM users;
SQL
// cron like syntax
schedule = "* * * * *"
// here you need to build the text message that will be sent
// to the slack channel.
// -------
// say(....): a function that will append the specified arguments into the main slack text message.
// log(....): a logger function, for debugging purposes.
// $rows: a variable that holds the output of the query execution.
message = <<JS
if ( $rows.length < 1 ) {
return
}
say("there are (", $rows.length, ") new users!")
say("users list is:")
_.chain($rows).pluck('name').each(function(name){
say("- ", name, " .")
})
JS
}