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

Per-command dependency injection #1679

Merged
merged 2 commits into from
Feb 8, 2024
Merged

Conversation

danepowell
Copy link
Contributor

I'm frequently discouraged from adding new commands if they would require adding a new dependency to the service container, since this requires adding the dependency to our already-massive CommandBase constructor as well as all the places its invoked. This is a pain to maintain.

And of course, there are performance considerations in building a service container with every possible dependency for every possible command every time the application is run.

It would be a lot better to only inject the dependencies necessary for a specific command when that command is run. This PR sets a precedent for that pattern and makes some progress by removing the Guzzle Client and Logstream Manager as base dependencies.

I'd really love to kill the CommandBase entirely, but I haven't figured out how to handle dependencies that are universal or nearly-universal, such as the Telemetry and Credentials helpers.

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (6d963af) 91.30% compared to head (c1fce4c) 91.27%.

Files Patch % Lines
src/Command/CommandBase.php 91.81% 14 Missing ⚠️
src/Command/Pull/PullCommand.php 33.33% 4 Missing ⚠️
src/Command/Pull/PullDatabaseCommand.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1679      +/-   ##
============================================
- Coverage     91.30%   91.27%   -0.03%     
- Complexity     1786     1789       +3     
============================================
  Files           122      122              
  Lines          6373     6375       +2     
============================================
  Hits           5819     5819              
- Misses          554      556       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danepowell danepowell merged commit 18a4a61 into acquia:main Feb 8, 2024
11 of 14 checks passed
@danepowell danepowell deleted the di-commands branch September 20, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant