Circular dependency vs. a single root config.lua file #29

Closed
opened 2023-02-20 14:34:48 +00:00 by CSDUMMI · 11 comments
CSDUMMI commented 2023-02-20 14:34:48 +00:00 (Migrated from gitlab.com)

I'm facing a problem, that appears to have no nice solution.

We want to have a single config file that imports other configuration files (pipeline and actions) and combines them into a single table, which is then merged with the configuration table provided by the user.

The reason we haven't done this before is because it leads to a circular dependency when defining the pipeline using checks and importing the configuration table from checks.

flowchart TD

    config --> pipeline

    pipeline --> checks

    checks --> WholeWordCheck

    WholeWordCheck --> config

(The same circularity applies to all checks using global configuration variables)

We have four options to resolve this circular dependency problem:

  1. Remove pipeline from the config table and have two independent configuration files
  2. Remove checks from pipeline and use dependency injection
  3. Remove config from WholeWordCheck and use dependency injection on new.
  4. Remove global configuration from all checks.

The first option is undesirable, because it makes the configuration of instances more complicated (a far more common activity than implementing a new action/check).

The second option, too, makes modifying the default pipeline more complicated, because the pipeline would now have to return a function (taking checks as an argument) instead of simply returning a table. This is still a more common activity than implementing a new check or action.

The third option is more involved, because it means that a checks run function would have to accept the global configuration (we cannot use the new function because this is called when creating the pipeline and before a configuration table is available).

The fourth option has the big disadvantage that checks are limited to only using configuration provided to it directly and cannot access global config, which would mean that both the WholeWordCheck and DomainCheck could no longer be maintained, because they use the global additional_config_path variable. I'd have to remove them. Checks relying on web sources (SubscriptionsDomainCheck) will not be impacted by this change.

Whatever option we choose, I'd implement it both for actions and checks.

I'm facing a problem, that appears to have no nice solution. We want to have a single `config` file that imports other configuration files (`pipeline` and `actions`) and combines them into a single table, which is then merged with the configuration table provided by the user. The reason we haven't done this before is because it leads to a circular dependency when defining the pipeline using checks and importing the configuration table from checks. ```mermaid flowchart TD config --> pipeline pipeline --> checks checks --> WholeWordCheck WholeWordCheck --> config ``` (The same circularity applies to all checks using global configuration variables) We have four options to resolve this circular dependency problem: 1. Remove pipeline from the config table and have two independent configuration files 2. Remove checks from pipeline and use dependency injection 3. Remove config from WholeWordCheck and use dependency injection on `new`. 4. Remove global configuration from all checks. The first option is undesirable, because it makes the configuration of instances more complicated (a far more common activity than implementing a new action/check). The second option, too, makes modifying the default pipeline more complicated, because the pipeline would now have to return a function (taking `checks` as an argument) instead of simply returning a table. This is still a more common activity than implementing a new check or action. The third option is more involved, because it means that a checks `run` function would have to accept the global configuration (we cannot use the `new` function because this is called when creating the `pipeline` and before a configuration table is available). The fourth option has the big disadvantage that checks are limited to only using configuration provided to it directly and cannot access global config, which would mean that both the `WholeWordCheck` and `DomainCheck` could no longer be maintained, because they use the global `additional_config_path` variable. I'd have to remove them. Checks relying on web sources (SubscriptionsDomainCheck) will not be impacted by this change. Whatever option we choose, I'd implement it both for `actions` and `checks`.
CSDUMMI commented 2023-02-20 14:34:48 +00:00 (Migrated from gitlab.com)

assigned to @CSDUMMI

assigned to @CSDUMMI
CSDUMMI commented 2023-02-20 14:34:54 +00:00 (Migrated from gitlab.com)

created branch 29-circular-dependency-vs-a-single-root-config-lua-file to address this issue

created branch [`29-circular-dependency-vs-a-single-root-config-lua-file`](/babka_net/activitycolander/-/compare/main...29-circular-dependency-vs-a-single-root-config-lua-file) to address this issue
CSDUMMI commented 2023-02-20 14:37:04 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
CSDUMMI commented 2023-02-20 14:43:50 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
CSDUMMI commented 2023-02-20 14:45:25 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
CSDUMMI commented 2023-02-20 14:48:31 +00:00 (Migrated from gitlab.com)

mentioned in commit 17d4a92c1c046aab6cc66e32d3ac693739131292

mentioned in commit 17d4a92c1c046aab6cc66e32d3ac693739131292
CSDUMMI commented 2023-02-20 14:49:15 +00:00 (Migrated from gitlab.com)

mentioned in commit 3fc6d1ea34d5b22e82eb1ef7e72406efa78ad4d4

mentioned in commit 3fc6d1ea34d5b22e82eb1ef7e72406efa78ad4d4
CSDUMMI commented 2023-02-20 14:56:24 +00:00 (Migrated from gitlab.com)

mentioned in commit c5c9c92306373873ea706b908b25a42cae73a99b

mentioned in commit c5c9c92306373873ea706b908b25a42cae73a99b
CSDUMMI commented 2023-02-20 15:03:27 +00:00 (Migrated from gitlab.com)

mentioned in commit 034ed73109d44a1c8de87aedcf8651042dd4509d

mentioned in commit 034ed73109d44a1c8de87aedcf8651042dd4509d
CSDUMMI commented 2023-02-20 17:48:10 +00:00 (Migrated from gitlab.com)

mentioned in commit 3faf45e1da

mentioned in commit 3faf45e1dac77f361799e2894ffd7858bead679c
CSDUMMI commented 2023-03-01 12:13:55 +00:00 (Migrated from gitlab.com)

This has been addressed by version 0.7.0 of ActivityColander. Global configuration has been removed from checks (option 4).

This has been addressed by version 0.7.0 of ActivityColander. Global configuration has been removed from checks (option 4).
CSDUMMI (Migrated from gitlab.com) closed this issue 2023-03-01 12:13:56 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
babka/activitycolander#29
No description provided.