Package Data | |
---|---|
Maintainer Username: | rap2hpoutre |
Maintainer Contact: | raphaelht@gmail.com (rap2hpoutre) |
Package Create Date: | 2015-10-02 |
Package Last Update: | 2020-09-30 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-21 03:02:43 |
Package Statistics | |
---|---|
Total Downloads: | 10,160 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 4 |
Total Forks: | 0 |
Total Open Issues: | 0 |
composer require rap2hpoutre/nestor
Run some tasks. In this example, the second task fails, everything will be rolled back.
$nestor = new Nestor\Servant;
// Create 1st task
$nestor->task()
->up(function (){
echo "task 1 done\n";
})
->down(function () {
echo "task 1 cancelled\n";
});
// Create 2nd task (will fail)
$nestor->task()
->up(function ($nestor) {
$nestor->fail();
echo "task 2 done\n";
})
->down(function () {
echo "task 2 cancelled\n";
});
// Run all tasks, rollback on fail (LIFO stack)
$nestor->run();
You should see:
task 1 done
task 2 cancelled
task 1 cancelled
Todo: Explain why.
Thanks to DonoSybrix. Feel free to contribute.