* chore: rename container to cosmossdk.io/container * fix imports * add replace for container * remove replace * add replace * fix replace * fix replace * fix replace * fix replace * fix replace * try to fix replace * rename to depinject * rename to depinject * do not use vanity URL for now * try fix tests * try fix tests * try fix tests * build -> inject * build -> inject * go mod tidy * fix dep vulnerability * fix dep vulnerability * fix Dockerfile for liveness-test * fix codeql error * try to solve dependency review * try to solve dependency review * go mod tidy * try to fix tests * another try
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package depinject
|
|
|
|
import (
|
|
"reflect"
|
|
)
|
|
|
|
// ModuleKey is a special type used to scope a provider to a "module".
|
|
//
|
|
// Special module-scoped providers can be used with Provide and ProvideInModule
|
|
// by declaring a provider with an input parameter of type ModuleKey. These
|
|
// providers may construct a unique value of a dependency for each module and
|
|
// will be called at most once per module.
|
|
//
|
|
// When being used with ProvideInModule, the provider will not receive its
|
|
// own ModuleKey but rather the key of the module requesting the dependency
|
|
// so that modules can provide module-scoped dependencies to other modules.
|
|
//
|
|
// In order for a module to retrieve their own module key they can define
|
|
// a provider which requires the OwnModuleKey type and DOES NOT require ModuleKey.
|
|
type ModuleKey struct {
|
|
*moduleKey
|
|
}
|
|
|
|
type moduleKey struct {
|
|
name string
|
|
}
|
|
|
|
func (k ModuleKey) Name() string {
|
|
return k.name
|
|
}
|
|
|
|
var moduleKeyType = reflect.TypeOf(ModuleKey{})
|
|
|
|
// OwnModuleKey is a type which can be used in a module to retrieve its own
|
|
// ModuleKey. It MUST NOT be used together with a ModuleKey dependency.
|
|
type OwnModuleKey ModuleKey
|
|
|
|
var ownModuleKeyType = reflect.TypeOf((*OwnModuleKey)(nil)).Elem()
|