3 ms·
In that case, it doesn't help much. For Plan 9 mk, there's a way to use a custom condition to decide if the action should be executed: rule:P check_query.r
by ori_b 9y ago
In that case, it doesn't help much. For Plan 9 mk, there's a way to use a custom condition to decide if the action should be executed:
rule:P check_query.rc: prereq rules
doaction
Where check_query may be a small shell script:
#!/bin/rc
# redirect stdin/stdout to /mnt/sql/ctl
<> /mnt/sql/ctl {
# send the query to the DB
echo query
# print the response, check it for
# your condition.
cat `{sed 1q} | awk '$2 != "condition"{exit(1)}'
}
But I'm not familiar with an alternative using Make. You'd have to do something like:
.PHONY: rule
rule: prereq rules
check_query.sh && doaction
- lisper 9y ago> You'd have to do something like: That's exactly right, but notice that you are not actually using make at all any more at this point, except as a vehicle to run check_query.sh && doaction which is doing all work.
- ori_b 9y agoIt's being used to manage the ordering of that with other rules, and to run independent steps in parallel.
- lisper 9y agoOK. So here's a scenario: I have a DB table that keeps track of email notifications sent out. There is a column for the address that the email was sent to, and another for the time at which the email was sent. A second table keeps track of replies (e.g. clicks on an embedded link in the email). Feel free to assume additional columns (e.g. unique ids) as needed. When some particular event occurs, I want the following to happen: 1. An email gets sent to a user 2. If there is no reply within a certain time frame, the email gets sent again 3. The above is repeated 3 times. If there is still no reply, a separate notification is sent to an admin account. That is a common scenario, and trivial to implement as code. Show me how make would help here.
- ori_b 9y agoI wouldn't; I don't think that make is a great fit for that kind of long running job. It's a great tool for managing DAGs of dependent, non-interactive, idempotent actions. You have no DAG, and no actions that can be considered fresh/stale, so there's nothing for make to help with. SQL doesn't have much to do with that.