Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#328] Introduce subcommand config-get. #333

Closed
wants to merge 1 commit into from

Conversation

fluca1978
Copy link
Collaborator

This commit introduces the pgagroal-cli subcommand config-get that allows the user to query the running pgagroal instance and obtain the value of a configuration parameter.

A new management action, named ACTION_CONFIG_GET, is added to manage the communication over the socket between pgagroal-cli and the main pgagroal process.
A few utility functions to handle the communication have been introduced to send data over the socket and receive it on the socket.

Moreover, different utility functions to print out the value of a configuration setting have been introduced, so that for instance all the boolean values are always mapped to "on" and "off".

The pgagroal-cli config-get command accepts a key to search. Usually the key is searched into the global configuration namespace, that is the section [pgagroal]. However, it is possible to define other keys that can be handled:

  • server.<server-name>.<what> will search 'what' within the server section named [server-name], as an example server.venkman.host;
  • limit.<database>.<what> will search 'what' within the pgagroal_databases.conf file entries (runtime) for the specified database name;
  • hba.<user>.<what> will search 'what' among the runtime HBA configuration for the user 'user'.

Note that in the case of 'hba.' and 'limit.', since the username or database name can appear multiple times, only the first occurency is matched. The match happens in a simple way, so for instance the database name 'foo' does not match an entry with 'all'.

It is also possible to specify a key starting with pgagroal., that will instrument the search within the global namespace. Therefore max_entries and pgagroal.max_entries are the same search terms.

If a key is not found, the main pgagroal process issue a warning in the logs, while the application pgagroal-cli does receive an empty answer and therefore does nothing.
Even in the case of a non-existing key, pgagroal-cli exists normally, to indicate that the query has been performed well, simply with no meaningful answer.

If pgagroal-cli is running with --verbose flag, the application prints the configuration entry with the key and the value, like in

pgagroal-cli get-config max_entries
max_entries = 300

this is useful for humans, but not for automated systems, so the default way of answering a query is by printing only the value

pgagroal-cli get-config max_entries
300

Documentation updated.
Shell completions updated.

Close #328

This commit introduces the `pgagroal-cli` subcommand `config-get` that
allows the user to query the running `pgagroal` instance and obtain
the value of a configuration parameter.

A new management action, named ACTION_CONFIG_GET, is added to manage
the communication over the socket between `pgagroal-cli` and the main
`pgagroal` process.
A few utility functions to handle the communication have been
introduced to send data over the socket and receive it on the socket.

Moreover, different utility functions to print out the value of a
configuration setting have been introduced, so that for instance all
the boolean values are always mapped to "on" and "off".

The `pgagroal-cli config-get` command accepts a key to search. Usually
the key is searched into the global configuration namespace, that is
the section `[pgagroal]`. However, it is possible to define other keys
that can be handled:
- `server.<server-name>.<what>` will search 'what' within the server
section named `[server-name]`, as an example `server.venkman.host`;
- `limit.<database>.<what>` will search 'what' within the
pgagroal_databases.conf file entries (runtime) for the specified
database name;
- `hba.<user>.<what>` will search 'what' among the runtime HBA
configuration for the user 'user'.

Note that in the case of 'hba.' and 'limit.', since the username or
database name can appear multiple times, only the first occurency is
matched. The match happens in a simple way, so for instance the
database name 'foo' does not match an entry with 'all'.

It is also possible to specify a key starting with `pgagroal.`, that
will instrument the search within the global namespace. Therefore
`max_entries` and `pgagroal.max_entries` are the same search terms.

If a key is not found, the main `pgagroal` process issue a warning in
the logs, while the application `pgagroal-cli` does receive an empty
answer and therefore does nothing.
Even in the case of a non-existing key, `pgagroal-cli` exists normally, to
indicate that the query has been performed well, simply with no
meaningful answer.

If `pgagroal-cli` is running with `--verbose` flag, the application
prints the configuration entry with the key and the value, like in

    pgagroal-cli get-config max_entries
    max_entries = 300

this is useful for humans, but not for automated systems, so the
default way of answering a query is by printing only the value

    pgagroal-cli get-config max_entries
    300

Documentation updated.
Shell completions updated.

Close agroal#328
@jesperpedersen
Copy link
Collaborator

Rebased, and merged.

Thanks for your contribution !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Obtain runtime configuration via pgagroal-cli
2 participants