Skip to content

Commit

Permalink
Add dns_cache so server addresses are cached and invalidated when DNS…
Browse files Browse the repository at this point in the history
… changes.

Adds a module to deal with dns_cache feature. It's
main struct is CachedResolver, which is a simple thread safe
hostname <-> Ips cache with the ability to refresh resolutions
every `dns_max_ttl` seconds. This way, a client can check whether its
ip address has changed.
  • Loading branch information
magec committed Dec 7, 2022
1 parent b9b5635 commit 8bed231
Show file tree
Hide file tree
Showing 10 changed files with 627 additions and 0 deletions.
230 changes: 230 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ rustls-pemfile = "1"
hyper = { version = "0.14", features = ["full"] }
phf = { version = "0.11.1", features = ["macros"] }
exitcode = "1.1.2"
trust-dns-resolver = "0.22"

[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = "0.5.0"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ The config can be reloaded by sending a `kill -s SIGHUP` to the process or by qu
| `default_role` | no |
| `primary_reads_enabled` | no |
| `query_parser_enabled` | no |
| `dns_max_ttl` | no |
| `dns_cache_enabled` | no |


## Benchmarks
Expand Down
9 changes: 9 additions & 0 deletions examples/docker/pgcat.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ log_client_disconnections = false
# Reload config automatically if it changes.
autoreload = false

# If enabled, hostname resolution will be cached and
# and server connections will be invalidated if a change on the ip is
# detected. This check is done every `dns_max_ttl` seconds.
# dns_cache_enabled = false

# The number of seconds to wait until we check again the
# cached hostnames resolution. 30 seconds by default.
# dns_max_ttl = 30

# TLS
# tls_certificate = "server.cert"
# tls_private_key = "server.key"
Expand Down
Loading

0 comments on commit 8bed231

Please sign in to comment.