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

Automatic resolution of shared component conflitcs caused by per-role config conflicts #2038

Open
pshirshov opened this issue Nov 13, 2023 · 1 comment
Assignees
Labels
complex A hard problem distage (di) philosoraptor Something we are just thinking about
Milestone

Comments

@pshirshov
Copy link
Member

Currently we may have effective role incompatibilities caused by the need in config variations. We may have a shared component S requiring config section C and two roles, R1 and R2. If these two roles need to have some value in C set to different/conflicting values we are screwed.

Current state

Currently we can only alleviate this problem by redesigning our application in order to avoid configuration conflicts.

For example:

Instead of having

role1.conf:

postgres = { uri = "..."}
role2.conf:

postgres = { uri = "..."}

We may write

shared.conf:

postgres = { 
role1 = {uri = "..."}
role2 = {uri = "..."}
}

Then we'll need a smart connection component which would reuse underlying connection for the same URIs.

Desired changes

We might automate this.

The key idea is simple:

  1. While we trace the object graph, we should look for configurable components
  2. When we find such a component, we should check which roles retain it
  3. We should load role configs individually and check if there are conflicts in the corresponding sections. If there are no conflicts we may configure the component straight away. If there are conflicts, we should create multiple copies of the rest of the graph, one per conflicting version.

We can definitely do the splits because we know that the graph has specific shape: generally there are NO dependencies between the roots.

I can't see a way to fit this into existing tracing pass, so probably this should be done as a separate pass which happens right after semigraph resolution.

@pshirshov pshirshov added distage (di) philosoraptor Something we are just thinking about complex A hard problem labels Nov 13, 2023
@pshirshov pshirshov added this to the 1.2 milestone Nov 13, 2023
@pshirshov pshirshov self-assigned this Nov 13, 2023
@neko-kai
Copy link
Member

By doing this we'd lose the guarantee that all our components are singleton and make things too complex / untraceable. As for reading from a role config instead of shared config, we could make this explicit:

makeRoleConfig[PostgresConfig](Role.id)("postgres")

@neko-kai neko-kai changed the title Automatic resolution shared component conflics caused by per-role config conflicts Automatic resolution of shared component conflitcs caused by per-role config conflicts Dec 2, 2023
@github-project-automation github-project-automation bot moved this to To do in DIStage Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complex A hard problem distage (di) philosoraptor Something we are just thinking about
Projects
Status: To do
Development

No branches or pull requests

2 participants