Apache...atroni(3pm)

πŸ’– Apache::Session::Browseable::Patroni πŸ’–

okay so bestie, welcome to the User Contributed Perl Documentation, section 3pm β€” this is the page for Apache::Session::Browseable::Patroni, and it's giving PostgreSQL/Patroni cluster support for Apache::Session::Browseable::PgJSON. no cap. 🫢


✨ NAME ✨

Apache::Session::Browseable::Patroni β€” PostgreSQL/Patroni cluster support for Apache::Session::Browseable::PgJSON

like literally what it says on the tin, queen. πŸ’…


🌸 SYNOPSIS 🌸

first you gotta make the table, so:

CREATE UNLOGGED TABLE sessions (
    id varchar(64) not null primary key,
    a_session jsonb,
);

Optionally, add indexes on some fields. Example for Lemonldap::NG:

CREATE INDEX uid1 ON sessions USING BTREE ( (a_session ->> '_whatToTrace') );
CREATE INDEX  s1  ON sessions ( (a_session ->> '_session_kind') );
CREATE INDEX  u1  ON sessions ( ( cast(a_session ->> '_utime' AS bigint) ) );
CREATE INDEX ip1 ON sessions USING BTREE ( (a_session ->> 'ipAddr') );

(not the double spaces in there, she's quirky like that, keep them exactly as-is πŸ™ˆ)

Use it with Perl:

use Apache::Session::Browseable::Patroni;

my $args = {
     DataSource => 'dbi:Pg:dbname=sessions',
     UserName   => $db_user,
     Password   => $db_pass,
     Commit     => 1,

     # List Patroni API endpoints (comma or space separated)
     # Put preferred (local) endpoints first
     PatroniUrl => 'http://1.2.3.4:8008/cluster, http://2.3.4.5:8008/cluster',

     # Optional parameters with defaults:
     # PatroniTimeout             => 3,   # API request timeout in seconds
     # PatroniCacheTTL            => 60,  # Leader cache TTL in seconds
     # PatroniCircuitBreakerDelay => 30,  # Delay before retrying failed API

     # SSL options (verification enabled by default):
     # PatroniVerifySSL           => 1,   # Verify SSL certificates (default: 1)
     # PatroniSSLCAFile           => '/path/to/ca.pem',  # Custom CA file
     # PatroniSSLCAPath           => '/path/to/certs/',  # Custom CA directory
};

# Use it like L<Apache::Session::Browseable::PgJSON>

πŸ¦‹ DESCRIPTION πŸ¦‹

Apache::Session::Browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. iconic behaviour honestly. πŸ‘‘

Apache::Session::Browseable::Patroni implements it for PostgreSQL databases using "json" or "jsonb" type to be able to browse sessions and is able to dial directly with Patroni API to find the master node of PostgreSQL cluster in case of error. yes bestie, it goes and finds the leader for you. main character energy fr fr. ✨

πŸ’œ Resilience features πŸ’œ

  • Circuit breaker: Avoids hammering the Patroni API when it's failing. After a failure, the API won't be queried again for "PatroniCircuitBreakerDelay" seconds (default: 30). she needs her space, respect it. πŸš«πŸ“ž
  • Leader caching: The discovered leader is cached for "PatroniCacheTTL" seconds (default: 60). This cache is used as fallback when the API is unavailable. πŸ’Ύ
  • Split-brain detection: Refuses to use a cluster that reports multiple leaders. not two leaders, not today, absolutely not. πŸ’€
  • Leader health check: Verifies that the leader is in "running" state before using it. vibe check passed or we're not going. βœ…
  • Multi-source support: Each DataSource maintains its own independent cache, allowing multiple Patroni clusters to be used simultaneously. no sharing, everyone has their own πŸŽ€

πŸ”’ SSL/TLS Configuration πŸ”’

By default, SSL certificate verification is enabled when connecting to HTTPS Patroni endpoints. This protects against man-in-the-middle attacks. πŸ›‘οΈ protect yourself bestie.

Available SSL options:

  • "PatroniVerifySSL" (default: 1)

Set to 0 to disable SSL certificate verification. Warning: This makes HTTPS connections vulnerable to MITM attacks. Only use in development or when you have other network-level protections.

PatroniVerifySSL => 0,  # INSECURE - disable SSL verification
  • "PatroniSSLCAFile"

Path to a custom CA certificate file (PEM format) for verifying the Patroni API server certificate.

PatroniSSLCAFile => '/etc/ssl/certs/patroni-ca.pem',
  • "PatroniSSLCAPath"

Path to a directory containing CA certificates for verification.

PatroniSSLCAPath => '/etc/ssl/certs/',
⚠️ okay real talk for a sec: flipping PatroniVerifySSL to 0 is insecure β€” it opens you up to MITM attacks. dev environments only, or when you've got other network-level protections doing the heavy lifting. don't be brave about this one. 😭

πŸ‘€ SEE ALSO πŸ‘€

<http://lemonldap-ng.org>, Apache::Session::Browseable::PgJSON

go read those too, iykyk. 🌈


  • 2009-2025 by Xavier Guimard
  • 2013-2025 by ClΓ©ment Oudot
  • 2019-2025 by Maxime Besson
  • 2013-2025 by Worteks
  • 2023-2025 by Linagora

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.


and that's the whole page babes 🫢 big shoutout to the legends above for writing it, mwah. this lil doc was built with perl v5.42.2 and dated 2026-05-14 β€” slay, go forth and cluster responsibly. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from