DBIO-PostgreSQL-Async

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# DBIO-PostgreSQL-Async

Async PostgreSQL storage for [DBIO](https://metacpan.org/pod/DBIO) using
[EV::Pg](https://metacpan.org/pod/EV::Pg).

Bypasses DBI entirely - speaks libpq's async protocol directly for
maximum performance (124k queries/sec in pipeline mode).

## Features

- **Non-blocking queries** - returns Futures, never blocks the event loop
- **Pipeline mode** - batch queries in a single network round-trip
- **LISTEN/NOTIFY** - real-time event streaming from PostgreSQL
- **COPY** - bulk data loading at wire speed
- **Connection pooling** - with transaction pinning
- **AccessBroker support** - `Schema->connect($broker)` with broker-refreshed conninfo for new pool connections
- **Sync fallback** - `->all`, `->first` etc. still work (blocking)

## Synopsis

```perl
my $schema = MyApp::Schema->connect(
    'DBIO::PostgreSQL::Async',
    {
        host      => 'localhost',
        dbname    => 'myapp',
        pool_size => 10,
    },
);

use DBIO::AccessBroker::Static;

my $broker = DBIO::AccessBroker::Static->new(
    dsn      => 'dbi:Pg:dbname=myapp;host=localhost',
    username => 'myapp',
    password => 'secret',
);

my $brokered = MyApp::Schema->connect($broker);

# Async
$schema->resultset('Artist')->all_async->then(sub {
    my @artists = @_;
    say $_->name for @artists;
});

# Pipeline
$schema->storage->pipeline(sub {
    Future->needs_all(
        map { $schema->resultset('Artist')->create_async({ name => $_ }) }
        @names
    );
});

# LISTEN/NOTIFY
$schema->storage->listen('events', sub {
    my ($channel, $payload) = @_;
    say "Got: $payload";
});
```

## Async

The storage class returns [Future](https://metacpan.org/pod/Future) objects for all query operations,
enabling fully non-blocking database access.

## Pipeline

Pipeline mode batches multiple queries into a single network round-trip.

## LISTEN/NOTIFY

PostgreSQL's publish/subscribe system for real-time notifications.



( run in 0.521 second using v1.01-cache-2.11-cpan-0b5f733616e )