Archived
1
0
Fork 0
Handle and cache basic Patroni API checks
This repository has been archived on 2024-12-18. You can view files and clone it, but cannot push or open issues or pull requests.
Find a file
Julien Riou e9cdacb0a8
End of life notice
Signed-off-by: Julien Riou <julien@riou.xyz>
2024-12-18 12:05:21 +01:00
extra Add deprecation note 2019-12-21 09:35:02 +01:00
src Add read-write, read-only and primary routes 2019-08-16 19:11:27 +02:00
.pre-commit-config.yaml Add pre-commit file 2019-03-08 18:31:17 +01:00
build.sh Initial release 2019-03-08 18:22:16 +01:00
config.yml.example Add TLS configuration 2019-04-13 16:30:04 +02:00
LICENSE Initial commit 2019-03-08 18:10:33 +01:00
README.md End of life notice 2024-12-18 12:05:21 +01:00
VERSION Add read-write, read-only and primary routes 2019-08-16 19:11:27 +02:00

END OF LIFE NOTICE

Stability issues with the Patroni API have been solved by upstream.

patroniglue

Handle and cache basic Patroni API checks

Patroni uses the built-in Python HTTP server to expose database states. It's perfect to be used by a load balancer like HAProxy to achieve high-availability. But, sometimes, this interface freezes. There's an open issue we are trying to close actively. As production doesn't wait, patroniglue was created to offload those checks and release pressure by adding a little response cache.

Usage

Start process using a configuration file:

patroniglue -config config.yml

Add more logging output:

patroniglue -config config.yml -verbose

Print usage:

patroniglue -help

Configuration

Configuration file format is YAML.

  • frontend: settings to handle incoming requests
    • host: address to handle requests (localhost by default)
    • port: port to handle requests (80 by default)
    • certfile: path to SSL certificate file (will use HTTP by default if not provided)
    • keyfile: path to SSL private key file (will use HTTP by default if not provided)
    • tls-min-version: minimum TLS version for HTTPS service (could be SSLv3.0, TLSv1.0,TLSv1.1, TLSv1.2, TLSv1.3)
    • tls-ciphers: list of supported ciphers (see full list)
  • backend: settings for sending requests to a backend
    • host: patroni REST API listen address
    • port: patroni REST API listen port
    • scheme: patroni REST API scheme (either http or https)
    • insecure: disable certificate checks on HTTPS requests
  • cache: settings for the caching system
    • ttl: time in second before response will be evinced
    • interval: time in second used by the internal cache loop to check for keys to remove

See config.yml.example file for an example.

Internals

  • Frontend handles HTTP or HTTPS requests on "/primary", "/master", "/replica", "/read-write" and "/read-only" routes available on Patroni API
  • Backend requests Patroni API using HTTP or HTTPS protocol and exposes state to frontend
  • Cache implements an in-memory key-value store to cache backend responses for some time

Build

Run ./build.sh script and enjoy!