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

Load services.php before configuration to allow container customizations #45

Open
wants to merge 4 commits into
base: 2.0.x
Choose a base branch
from

Conversation

olsavmic
Copy link

@olsavmic olsavmic commented May 31, 2024

@olsavmic olsavmic changed the title Load services.php before configuration to allow container customizations WIP: Load services.php before configuration to allow container customizations May 31, 2024
@olsavmic olsavmic changed the title WIP: Load services.php before configuration to allow container customizations Load services.php before configuration to allow container customizations May 31, 2024
@gennadigennadigennadi
Copy link
Member

How does this help with overriding deptrac internal stuff?
And does this have an performance impact on cache projects?

FYI: I'll try to do some testing next week.

@olsavmic
Copy link
Author

olsavmic commented Jun 1, 2024

How does this help with overriding deptrac internal stuff?

It allows you to define services section in the configuration file which can override the defaults from services.php. It used to work like this in 1.x (https://github.com/qossmic/deptrac-src/blob/1.0.1/src/Supportive/DependencyInjection/ServiceContainerBuilder.php)

Screenshot 2024-06-01 at 14 44 55

And does this have an performance impact on cache projects?

I believe that the impact should be negligible, as the cache is still resolved as the very last step (once all services from both the services file and configuration are resolved).

Better to properly measure than to just hypothesize, of course :D Thank you!

@olsavmic
Copy link
Author

olsavmic commented Jun 7, 2024

@gennadigennadigennadi Do you have some specific set of benchmarks in mind? I can help you test that.

I don't see any reason why the runtime performance should be affected by my changes. The flow is following:

  1. Load default services definition into the container builder
  2. Load configuration (which includes the cache file definition)
    • this stage allows default service overrides
  3. Load the cacheFile (based on the configuration param)
  4. Build the DIC container (only at this point are the services, params etc. actually resolved) from the builder

I just ran the patched version on our codebase, and the cache works just fine :) And the service overrides as well.


I have added one more commit, to make the "service override experience" unified. I'll test the results again.

@olsavmic
Copy link
Author

olsavmic commented Jun 7, 2024

The total runtime for v1.0.2, 2.0.0 without patch and both patches here on our codebase (15 000+ files) is very consistent without any signs of degradation.

@gennadigennadigennadi
Copy link
Member

gennadigennadigennadi commented Jun 8, 2024

I just went through the changes and hadn't had enough time to properly think about the changes.

Right now I'm not sure what gets cached at all? I don't think the service definitions are.

Also, even if this changes get merged, there is no guarantee it will stay like this. This is nothing but a hack, until Deptrac officially exposes its internals.

And I don't think we will expose the Symfony container officially.

@patrickkusebauch
Copy link
Contributor

I think this is fine. It would be great if it included a test for the order of operation so that the next refactor of the loader does not break this again.

Furthermore, I think it would be good to expose more of Deptrac Interfaces in the contract. The individual Deptrac modules have been stable for quite a while now in terms of module boundaries. If @olsavmic and @janedbal could share the interfaces Shipmonk would be interested in overwriting, I could make some effort into putting them into the contract namespace.

@gennadigennadigennadi gennadigennadigennadi self-assigned this Jun 17, 2024
…ide consistent override behavior"

This reverts commit 627dae0.
@olsavmic
Copy link
Author

I have reverted the last commit to prevent the creation of a cache file when --no-cache was used, keeping the original behavior. The pipeline should pass now.

@olsavmic
Copy link
Author

olsavmic commented Jun 20, 2024

@patrickkusebauch We have two main use-cases, already discussed in:

@patrickkusebauch
Copy link
Contributor

patrickkusebauch commented Jun 20, 2024

I talked to Jan over lunch lasts week and we discussed having a Parser interface for you to use your custom parsing logic for creating the AST references and a Baseline mapper interface for you to have a custom baseline mapping implementation.

@olsavmic
Copy link
Author

@gennadigennadigennadi Can you please approve the workflow? Thank you!

@olsavmic
Copy link
Author

olsavmic commented Jul 2, 2024

The pipeline is green, can I please get a review & merge?

Even if we work on the extension points, this change helps to test customizations more quickly 🤔

Thank you!

@gennadigennadigennadi
Copy link
Member

I think this is fine. It would be great if it included a test for the order of operation so that the next refactor of the loader does not break this again.

I would really like to see a test for it, too. Otherwise it looks good.

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.

Unable to customize DIC services since 2.0
3 participants