Perinci::Tx::Util - Helper when writing transactional functions
This document describes version 0.39 of Perinci::Tx::Util (from Perl distribution Perinci-Tx-Util), released on 2015-09-04.
use Perinci::Tx::Util qw(use_other_actions); sub foo { my %args = @_; use_other_actions(actions => [ ["My::action1", {arg=>1}], ["My::action2", {arg=>2}], # ... ]); }
Generate envelope response for transactional function. Can be used to say that function entirely depends on other actions.
Each action in $actions will be called with -tx_action => 'check_state'. If all actions return 304, response status will be 304. If some or all actions return 200 and the rest 304, response status will be 200 with undo_actions result metadata taken from the actions' metadata and do_actions from $actions. If any action returns 412, response will be 412. If any action return other status, response will be 500 (error).
$actions
-tx_action => 'check_state'
undo_actions
do_actions
It is your responsibility to load required modules.
Does not perform checking on actions like Perinci::Tx::Manager, but eventually actions will be checked by Perinci::Tx::Manager anyway.
Perinci::Util
Perinci
Please visit the project's homepage at https://metacpan.org/release/Perinci-Tx-Util.
Source repository is at https://github.com/perlancar/perl-Perinci-Tx-Util.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Tx-Util
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Perinci::Tx::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perinci::Tx::Util
CPAN shell
perl -MCPAN -e shell install Perinci::Tx::Util
For more information on module installation, please visit the detailed CPAN module installation guide.