NAME
DBIx::QuickORM::STH::Fork - Statement handle backed by a forked child process.
DESCRIPTION
An asynchronous statement-handle variant whose query runs in a forked child process that streams JSON-encoded messages back over a pipe. The first message carries the driver result; each subsequent message is one row. ready peeks the pipe without blocking, result and row fetches block on it. Finalizing the handle drains the pipe, reaps the child, and releases the connection's fork slot; cancelling additionally signals the child with TERM.
SYNOPSIS
while (my $row_hr = $sth->next) { ... }
ATTRIBUTES
- connection
-
The owning connection.
- source
-
The source the rows belong to.
- only_one
-
When true, more than one row is an error.
- dialect
-
The dialect, lazily taken from the connection.
- ready
-
True once the result message has been read from the pipe.
- got_result
-
The driver result once it has been read; absent until then.
- done
-
True once iteration has finished and the handle has been finalized.
- pid
-
PID of the forked child process.
- pipe
-
The pipe object messages are read from.
PUBLIC METHODS
- $bool = $sth->cancel_supported
-
Always true: a forked query can be cancelled by signalling the child.
- $dialect = $sth->dialect
-
The dialect, lazily taken from the connection.
- $sth->clear
-
Release the fork slot on the owning connection.
- $sth->init
-
Constructor hook that validates required attributes.
- $bool = $sth->ready
-
Non-blocking peek at the pipe; true once the result message has been read.
- $result = $sth->result
-
Block on the pipe until the result message arrives, caching and returning it.
- $sth->cancel
-
Signal and reap the child process and finalize the handle.
- $row_hr = $sth->next
-
Return the next row as a hashref, or undef once exhausted. With
only_oneset, a second row is an error.
PRIVATE METHODS
- $row_hr = $sth->_next
-
Read and decode the next row message from the pipe, finalizing when the child signals exhaustion.
- $msg = $sth->_read_message($blocking)
-
Read one raw message from the pipe, blocking or not per the argument.
- $result = $sth->_decode_result($msg)
-
Decode the JSON result message and return its
resultpayload, croaking on invalid data. - $sth->set_done
-
Drain the pipe, reap the child, release the fork slot, and mark the handle done. Idempotent.
SOURCE
The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.