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

Feature Request: allow providers to accept name for service customization #88

Open
abenerd opened this issue Sep 26, 2024 · 0 comments
Open

Comments

@abenerd
Copy link

abenerd commented Sep 26, 2024

do.ProvideWithOnDemandName(injector, func (i Injector, name string) (Database, error) {
    return connection.GetDatabase(name)
})

do.InvokeNamed[Database](i, "tenant-1")
// or
do.InvokeOnDemandName[Database](i, "tenant-2")

The example shows the provider able to accept a name that is then used to customise the returned service. One might not always be willing or able to define all possible providers. This could of course be done by returning a factory method that does the actual retrieval but it would be nice to have this natively available. I this a feature that might be considered or would this be too much overhead for implement and maintain?

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

1 participant