NAME

Net::LibNFS::Async - Non-blocking I/O for Net::LibNFS

SYNOPSIS

After creating $nfs_async from a Net::LibNFS instance …

$nfs->mount("the.nfs.server", "/export-dir")->then(
    sub {
        return $nfs->stat("/");
    },
)->then(
    sub ($stat) {
        printf "mode(/) = 0%03o\n", $stat->mode() & 0777;
        return $nfs->open('/some-file', Fcntl::O_RDONLY);
    },
)->then(
    sub ($fh) {
        return $fh->read(120)->then(
            sub ($buf) {
                print $buf;
                return $fh->close();
            },
        );
    },
)->then(
    sub {
        return $nfs->umount();
    }
)

DESCRIPTION

This module exposes non-blocking counterparts to Net::LibNFS’s blocking I/O calls.

Its methods return promises. (Mozilla publishes a nice introduction to promises that may be of help if you’re unfamiliar with that pattern.)

NFS METHODS

The below all accept the same arguments as their equivalents in Net::LibNFS.

promise() = OBJ->mount( $SERVERNAME, $EXPORTNAME )

Promise resolves empty.

promise() = OBJ->umount()

Promise resolves empty.

promise($stat) = OBJ->stat( $PATH )

Promise resolves to a Net::LibNFS::Stat instance.

promise($stat) = OBJ->lstat( $PATH )

Promise resolves to a Net::LibNFS::Stat instance.

promise($fh) = OBJ->open( $PATH, $FLAGS [, $MODE] )

Promise resolves to a Net::LibNFS::Async::Filehandle instance.

promise() = OBJ->mkdir( $PATH [, $MODE] )

Promise resolves empty.

promise() = OBJ->rmdir( $PATH )

Promise resolves empty.

promise() = OBJ->chdir( $PATH )

Promise resolves empty.

promise() = OBJ->unlink( $PATH )

Promise resolves empty.

promise($dh) = OBJ->opendir( $PATH )

Promise resolves to a Net::LibNFS::Dirhandle instance.

promise($statvfs) = OBJ->statvfs( $PATH )

Promise resolves to a Net::LibNFS::StatVFS instance.

promise() = OBJ->mknod( $PATH, $MODE, $DEV )

Promise resolves empty.

promise() = OBJ->chmod( $PATH, $MODE )

Promise resolves empty.

promise() = OBJ->lchmod( $PATH, $MODE )

Promise resolves empty.

promise() = OBJ->chown( $PATH, $UID, $GID )

Promise resolves empty.

promise() = OBJ->lchown( $PATH, $UID, $GID )

Promise resolves empty.

promise() = OBJ->utime( $PATH, $ATIME, $MTIME )

Promise resolves empty.

promise() = OBJ->lutime( $PATH, $ATIME, $MTIME )

Promise resolves empty.

promise() = OBJ->truncate( $PATH, $LENGTH )

Promise resolves empty.

OTHER METHODS

promise(\@exports) = OBJ->mount_getexports( $SERVERNAME )

Promise resolves to an arrayref of hashrefs such as Net::LibNFS’s corresponding static function returns.

$obj = OBJ->pause()

Pauses all reads. (Writes still continue.)

Returns OBJ.

$obj = OBJ->resume()

The inverse of pause().