feat: Include and exclude databases

- Add filters to include and exclude strings
- Use filters to include and exclude sessions (user and databases supported)
- Add tests to filters and terminator

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2023-01-14 09:56:38 +01:00
commit 8709ee542b
No known key found for this signature in database
GPG key ID: A2EB1F2CA8E3F677
9 changed files with 553 additions and 53 deletions

View file

@ -107,6 +107,10 @@ When include users list or regex is set, `pgterminate` will focus on included us
When exclude users list or regex is set and no include option is set, `pgterminate` will terminate all sessions except excluded users.
# Filtering databases
Similar to users, `pgterminate` is able to filter sessions by database. The same set of options are available if you replace `user` by `database` (ex: `-include-user` to `-include-database` and so on).
# Listeners
LISTEN queries are asynchronous. Sessions are set to "idle" state even if they are waiting for messages to be sent to the queue. `pgterminate` can exclude sessions in that state by looking at the last known query starting with "LISTEN", with the `exclude-listeners` parameter.