EV-ClickHouse

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


    $ch->ping_round_trip(sub {
        my ($seconds, $err) = @_;
        die "ping: $err" if $err;
        printf "rtt = %.3fms\n", $seconds * 1000;
    });

Issue a single PING and report wall-clock latency in seconds. Lighter
than installing ["track\_query\_durations"](#track_query_durations) for a one-shot probe;
returns `(undef, $err)` on transport failure. Pairs well with
["is\_healthy"](#is_healthy) for health-check endpoints that want both liveness and
latency.

## slow\_query\_log

    my $prev = $ch->slow_query_log(0.1, sub {
        my ($qid, $rows, $bytes, $code, $dur, $err) = @_;
        warn sprintf("SLOW %.3fs %s\n", $dur, $qid // '?');
    });

Filtered variant of ["on\_query\_complete"](#on_query_complete) that fires only when the

eg/tls.pl  view on Meta::CPAN

#!/usr/bin/env perl
# TLS connection — connect over a TLS-fronted ClickHouse port.
#
# Set up a TLS endpoint (e.g. with stunnel or nginx) and point this script
# at it via CLICKHOUSE_TLS_HOST / CLICKHOUSE_TLS_PORT.
use strict;
use warnings;
use EV;
use EV::ClickHouse;

my $host = $ENV{CLICKHOUSE_TLS_HOST} // 'localhost';
my $port = $ENV{CLICKHOUSE_TLS_PORT} // 9440;
my $ca   = $ENV{CLICKHOUSE_TLS_CA};        # optional extra CA bundle

lib/EV/ClickHouse.pm  view on Meta::CPAN


    $ch->ping_round_trip(sub {
        my ($seconds, $err) = @_;
        die "ping: $err" if $err;
        printf "rtt = %.3fms\n", $seconds * 1000;
    });

Issue a single PING and report wall-clock latency in seconds. Lighter
than installing L</track_query_durations> for a one-shot probe;
returns C<(undef, $err)> on transport failure. Pairs well with
L</is_healthy> for health-check endpoints that want both liveness and
latency.

=head2 slow_query_log

    my $prev = $ch->slow_query_log(0.1, sub {
        my ($qid, $rows, $bytes, $code, $dur, $err) = @_;
        warn sprintf("SLOW %.3fs %s\n", $dur, $qid // '?');
    });

Filtered variant of L</on_query_complete> that fires only when the

t/75_lz4_features.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;
use EV;
use EV::ClickHouse;

# EVCH-3: LZ4 is bundled, and the build reports its capabilities.
# Class-level feature assertions need no server; the round-trip below
# exercises the bundled codec against a live native endpoint.

my $host = $ENV{TEST_CLICKHOUSE_HOST} || '127.0.0.1';
my $nport = $ENV{TEST_CLICKHOUSE_NATIVE_PORT} || 9000;

require IO::Socket::INET;
my $nat_ok = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $nport, Timeout => 2) ? 1 : 0;

plan tests => 10;

my $f = EV::ClickHouse->features;



( run in 0.950 second using v1.01-cache-2.11-cpan-eb134014566 )