1Rex::Transaction(3)   User Contributed Perl Documentation  Rex::Transaction(3)
2
3
4

NAME

6       Rex::Transaction - Transaction support.
7

DESCRIPTION

9       With this module you can define transactions and rollback scenarios on
10       failure.
11

SYNOPSIS

13        task "do-something", "server01", sub {
14          transaction {
15            on_rollback {
16              rmdir "/tmp/mydata";
17            };
18
19            mkdir "/tmp/mydata";
20            upload "files/myapp.tar.gz", "/tmp/mydata";
21            run "cd /tmp/mydata; tar xzf myapp.tar.gz";
22            if($? != 0) { die("Error extracting myapp.tar.gz"); }
23          };
24        };
25

EXPORTED FUNCTIONS

27   transaction($codeRef)
28       Start a transaction for $codeRef. If $codeRef dies it will rollback the
29       transaction.
30
31        task "deploy", group => "frontend", sub {
32           on_rollback {
33             rmdir "...";
34           };
35           deploy "myapp.tar.gz";
36        };
37
38        task "restart_server", group => "frontend", sub {
39           run "/etc/init.d/apache2 restart";
40        };
41
42        task "all", group => "frontend", sub {
43           transaction {
44             do_task [qw/deploy restart_server/];
45           };
46        };
47
48   on_rollback($codeRef)
49       This code will be executed if one step in the transaction fails.
50
51       See transaction.
52
53
54
55perl v5.30.0                      2019-07-24               Rex::Transaction(3)
Impressum