NAME

ZooKeeper::Transaction

SYNOPSIS

my $txn = $zk->transaction
             ->delete( '/some-node'    )
             ->create( '/another-node' )
my ($delete_result, $create_result) = $txn->commit;

DESCRIPTION

A ZooKeeper::Transaction is used for constructing a set of multiple operations, which must be committed atomically.

ERRORS

When any of the operations fail, all ops in the transaction will return hash refs with 'type' set to 'error', and with 'code' set to the error code for the operation.

METHODS

commit

Commit a transaction. Returns a list of op results.

create

$txn->create($path, %extra)

    REQUIRED $path

    OPTIONAL %extra
        acl
        buffer_length
        ephemeral
        sequential
        value

Return a tranaction with a create op code.

On commit this will return a hash ref with type 'create', and with 'path' set to the path to the new node.

delete

$txn->delete($path, %extra)

    REQUIRED $path

    OPTIONAL %extra
        version

Return a tranaction with a delete op code.

On commit this will return a hash ref with type 'delete'.

set

$txn->set($path, $value, %extra)

    REQUIRED $path
    REQUIRED $value

    OPTIONAL %extra
        version

Return a tranaction with a set op code.

On commit this will return a hash ref with type 'set', and with 'stat' set a stat hash ref of the updated node.

check

$txn->check($path, $version)

    REQUIRED $path
    REQUIRED $version

Return a tranaction with a check op code.

On commit this will return a hash ref with type 'check'.