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

[#120] Implement IoC Container #115

Merged
merged 26 commits into from
May 24, 2023
Merged

[#120] Implement IoC Container #115

merged 26 commits into from
May 24, 2023

Conversation

hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented May 6, 2023

@codecov
Copy link

codecov bot commented May 6, 2023

Codecov Report

Patch coverage: 59.00% and project coverage change: -0.80 ⚠️

Comparison is base (95ef25f) 53.06% compared to head (7b0f09e) 52.26%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
- Coverage   53.06%   52.26%   -0.80%     
==========================================
  Files         105      117      +12     
  Lines        7570     8099     +529     
==========================================
+ Hits         4017     4233     +216     
- Misses       3268     3566     +298     
- Partials      285      300      +15     
Impacted Files Coverage Δ
auth/console/jwt_secret_command.go 0.00% <0.00%> (ø)
auth/console/policy_make_command.go 65.51% <0.00%> (-4.86%) ⬇️
auth/service_provider.go 0.00% <0.00%> (ø)
cache/service_provider.go 0.00% <0.00%> (ø)
config/service_provider.go 0.00% <0.00%> (ø)
console/service_provider.go 0.00% <0.00%> (ø)
crypt/service_provider.go 0.00% <0.00%> (ø)
database/console/migrate_rollback_command.go 0.00% <0.00%> (ø)
database/console/model_make_command.go 67.74% <0.00%> (-4.68%) ⬇️
database/console/observer_make_command.go 67.74% <0.00%> (-4.68%) ⬇️
... and 70 more

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@hwbrzzl hwbrzzl changed the title Optimize service container [#120] Implement IoC Container May 6, 2023
func NewArtisan() console.Artisan {
return App().MakeArtisan()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Temporarily add NewArtisan, will replace Artisan: func NewArtisan() console.Artisan

Comment on lines 7 to 9
var Config = NewConfig()

func NewConfig() configcontract.Config {
return App().MakeConfig()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Temporarily add NewArtisan, will replace Config: func Config() configcontract.Config

@hwbrzzl hwbrzzl linked an issue May 6, 2023 that may be closed by this pull request
1 task
Copy link
Member

@devhaozi devhaozi left a comment

Choose a reason for hiding this comment

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

Looks no problems.

devhaozi
devhaozi previously approved these changes May 13, 2023
"github.com/goravel/framework/contracts/http"
"github.com/goravel/framework/facades"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of the modules shouldn't be dependent on facades and should inject if needed.

}

func (s *AuthTestSuite) TestLoginUsingID_EmptySecret() {
mockConfig := mock.Config()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of the test cases shouldn't be dependent on the github.com/goravel/framework/testing/mock package, will cause import cycle error, use &cachemock.Cache{} instead.

Comment on lines +19 to +26
app.Singleton(BindingAuth, func() (any, error) {
config := app.MakeConfig()
return NewAuth(config.GetString("auth.defaults.guard"),
app.MakeCache(), config, app.MakeOrm()), nil
})
app.Singleton(BindingGate, func() (any, error) {
return access.NewGate(context.Background()), nil
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bind and inject like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use wire to implement dependency injection.

Copy link
Member

@devhaozi devhaozi left a comment

Choose a reason for hiding this comment

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

LGTM

devhaozi
devhaozi previously approved these changes May 20, 2023
Copy link
Member

@devhaozi devhaozi left a comment

Choose a reason for hiding this comment

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

LGTM

@hwbrzzl hwbrzzl merged commit a745ff3 into master May 24, 2023
@hwbrzzl hwbrzzl deleted the bowen/#120 branch May 24, 2023 15:00
hwbrzzl added a commit that referenced this pull request May 26, 2023
* Optimize service container

* Adaptation Crypt module

* Adaptation Cache module

* Adaptation contracts

* Adaptation Event module

* Adaptation Foundation module

* Adaptation Queue module

* Adaptation DB module

* Adaptation filesystem module

* Adaptation filesystem module

* Adaptation facades module

* Adaptation Auth module

* Adaptation Http module

* Adaptation Grpc module

* Adaptation Log module

* Adaptation Mail module

* Adaptation Route module

* Adaptation Schedule module

* Adaptation Filesystem module

* Adaptation other module

* Adaptation Hash module

* Fix unit tests

* Optimize code

* Add unit tests

* Rebase

* Optimize unit tests
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.

✨ [Feature] Implement IoC Container
2 participants