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

fix: merge session mode pool config with main config, preserving options #293

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gf3
Copy link

@gf3 gf3 commented Oct 26, 2024

When providing a session mode pool config via session_mode_url, it's not clear that session_mode_url is parsed into a keyword list and replaces the parent config.

For example, we use the following configuration to connect to Digital Ocean's managed Postgres:

config :our_app, OurApp.EventStore,
  default_database: "defaultdb",
  serializer: Commanded.Serialization.JsonSerializer,
  url: event_store_database_url,
  session_mode_url: event_store_session_database_url,
  ssl: true,
  ssl_opts: [cacertfile: ~c"/etc/ssl/certs/db.ca-certificate.crt", verify: :verify_peer],
  prepare: :unnamed,
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
  socket_options: maybe_ipv6

The options ssl, ssl_opts, and prepare are particularly important to our connection and are not included when generating the config (session mode pool config) from the session_mode_url.

This PR merges the session mode pool config into the parent config before passing it along. So that all the specified configuration options are used for the session mode pool, too. Which, I think, is what people probably expect when looking at the above event store configuration.

Copy link
Contributor

@drteeth drteeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gf3, thanks so much for your contribution.

I can see that you are fixing a real world issue, and I'm sure it's correct, but I'm having trouble seeing that from the description of the issue and the code changes.

Can I ask you to include a test that fails without your change and passes with it? This way we won't break it again and the reason for the new implementation will be clear.

Let me know if you need any help with that.

@gf3 gf3 requested a review from drteeth November 27, 2024 18:29
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.

2 participants