From: Peter Rabbitson Date: Sun, 29 Mar 2009 23:05:37 +0000 (+0000) Subject: Take experimental off TxnScopeGuard X-Git-Tag: v0.08100~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6936e902c1291c14c8e73f9c9f016e5212ad4083;p=dbsrgits%2FDBIx-Class.git Take experimental off TxnScopeGuard --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index cf7267d..4254b1e 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -617,7 +617,7 @@ sub txn_do { $self->storage->txn_do(@_); } -=head2 txn_scope_guard (EXPERIMENTAL) +=head2 txn_scope_guard Runs C on the schema's storage. See L. diff --git a/lib/DBIx/Class/Storage.pm b/lib/DBIx/Class/Storage.pm index 604ad5b..eb87d4f 100644 --- a/lib/DBIx/Class/Storage.pm +++ b/lib/DBIx/Class/Storage.pm @@ -299,21 +299,25 @@ sub svp_rollback { die "Virtual method!" } =for comment -=head2 txn_scope_guard (EXPERIMENTAL) +=head2 txn_scope_guard -An alternative way of using transactions to C: +An alternative way of transaction handling based on +L: - my $txn = $storage->txn_scope_guard; + my $txn_guard = $storage->txn_scope_guard; $row->col1("val1"); $row->update; - $txn->commit; + $txn_guard->commit; -If a exception occurs, the transaction will be rolled back. This is still very -experiemental, and we are not 100% sure it is working right when nested. The -onus is on you as the user to make sure you dont forget to call -$C<$txn->commit>. +If an exception occurs, or the guard object otherwise leaves the scope +before C<< $txn_guard->commit >> is called, the transaction will be rolled +back by an explicit L call. In essence this is akin to +using a L/L pair, without having to worry +about calling L at the right places. Note that since there +is no defined code closure, there will be no retries and other magic upon +database disconnection. If you need such functionality see L. =cut diff --git a/lib/DBIx/Class/Storage/TxnScopeGuard.pm b/lib/DBIx/Class/Storage/TxnScopeGuard.pm index ca7cad7..e55691a 100644 --- a/lib/DBIx/Class/Storage/TxnScopeGuard.pm +++ b/lib/DBIx/Class/Storage/TxnScopeGuard.pm @@ -1,5 +1,4 @@ -package # Hide from pause for now - till we get it working - DBIx::Class::Storage::TxnScopeGuard; +package DBIx::Class::Storage::TxnScopeGuard; use strict; use warnings; @@ -47,7 +46,7 @@ __END__ =head1 NAME -DBIx::Class::Storage::TxnScopeGuard - Experimental +DBIx::Class::Storage::TxnScopeGuard - Scope-based transaction handling =head1 SYNOPSIS @@ -70,14 +69,15 @@ right thing with transactions in DBIx::Class. =head2 new -Creating an instance of this class will start a new transaction. Expects a +Creating an instance of this class will start a new transaction (by +implicitly calling L. Expects a L object as its only argument. =head2 commit Commit the transaction, and stop guarding the scope. If this method is not -called (i.e. an exception is thrown) and this object goes out of scope then -the transaction is rolled back. +called and this object goes out of scope (i.e. an exception is thrown) then +the transaction is rolled back, via L =cut