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

Suggestion: renaming Component to Singleton #8

Open
leinardi opened this issue Dec 9, 2020 · 2 comments
Open

Suggestion: renaming Component to Singleton #8

leinardi opened this issue Dec 9, 2020 · 2 comments

Comments

@leinardi
Copy link

leinardi commented Dec 9, 2020

Having used other popular dependency injection libraries for other languages, I find the use of the name Component a little misleading. My understanding is that, what is annotated with #[derive(Component)] will survive for the rest of the application runtime, with no other scope, which is what a singleton does and would match the javax.inject.Singleton behavior.

Dagger uses the name Component for something very different, that is way similar to what the shaku's module! macro does: https://developer.android.com/training/dependency-injection/dagger-basics#dagger-components

@AzureMarker
Copy link
Owner

I based the naming of "component" on how Spring and Autofac name the "service" classes "components". Dagger's naming in general seems to be a bit different than the rest of the DI libraries, so maybe a better name would be "Service", as that seems to be one thing all of the libraries have in common.

I think this issue should also include the name for what are currently called "providers". Some other possible names include "factories" and "scoped services" (scoping is another topic, but maybe better handled in a separate issue).

@wanderrful
Copy link

wanderrful commented Jun 22, 2023

FYI calling it a Service will conflict with the naming conventions of the axum crate, which uses that word for its transitive dependency crate, tower-service, and uses it as part of its own Router APIs.

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

No branches or pull requests

3 participants