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

feat: support kwargs for pg conn in pg_listener #383

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

Alex-Izquierdo
Copy link
Contributor

@Alex-Izquierdo Alex-Izquierdo commented Jan 23, 2025

What:
This PR adds support for a dictionary of pg_param:value for the connection follow the standard use of Connection.connect with backward compatibility. Also enhances the validation of plugin arguments, extends test coverage and update module docstring according to the changes.

  • New dict param postgres_params
  • Check that dsn or postgres_params are defined
  • Check required params (channels)
  • Check the right type of all the arguments

Why:
Psycopg library has native support for a dsn string and kwargs params. There is no need to force the definition of a connection string, key:value pairs are more usual and makes easier the integration since it can be handled as a structured data.

This is also related to ansible/eda-server#1176 and part of a series of efforts to improve how we handle pg_notify configuration.

How:
Adding the new option postgres_params and making both, postgres_params and dsn optional but at least one must be provided. Encapsulates validation logic in _validate_args Psycopg library handles automatically the merge of both methods, we only need to pass the kwargs.

@Alex-Izquierdo Alex-Izquierdo requested a review from a team January 23, 2025 12:45
@Alex-Izquierdo Alex-Izquierdo changed the title feat: support kwarg for pg conn in pg_listener feat: support kwargs for pg conn in pg_listener Jan 23, 2025
@Alex-Izquierdo Alex-Izquierdo added enhancement New feature or request and removed feature labels Jan 23, 2025
@Alex-Izquierdo Alex-Izquierdo requested a review from a team January 23, 2025 15:29
@Alex-Izquierdo Alex-Izquierdo merged commit 64a32f1 into ansible:main Jan 23, 2025
17 checks passed
@Alex-Izquierdo Alex-Izquierdo deleted the enhance-pg-conf branch January 23, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants