Documentation
¶
Index ¶
- func Activate[T any](resolver types.Resolver, ctx context.Context, activatorFunc any, ...) (T, error)
- func NewResolver(registry types.ServiceRegistry) types.Resolver
- func NewScopedContext(ctx context.Context) context.Context
- func ResolveRequiredService[T any](resolver types.Resolver, ctx context.Context) (T, error)
- func ResolveRequiredServices[T any](resolver types.Resolver, ctx context.Context) ([]T, error)
- func WithInstance[T any](instance T) types.ResolverOptionsFunc
- type NamedServiceResolverActivatorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Activate ¶
func Activate[T any](resolver types.Resolver, ctx context.Context, activatorFunc any, options ...types.ResolverOptionsFunc) (T, error)
Activate attempts to create and return an instance of the requested type using the provided resolver. Use this method to instantiate service objects of unregistered types. The specified activator function can have parameters to demand service instances for registered service types.
func NewResolver ¶
func NewResolver(registry types.ServiceRegistry) types.Resolver
NewResolver creates and returns a new Resolver instance based on the provided ServiceRegistry.
func NewScopedContext ¶
NewScopedContext creates a new context with an associated service instance map, useful for managing service lifetimes within scope.
func ResolveRequiredService ¶
ResolveRequiredService resolves a single service instance of the specified type using the given resolver and context. The method can return the following errors: ErrorCannotResolveService, ErrorAmbiguousServiceInstancesResolved.
func ResolveRequiredServices ¶
ResolveRequiredServices resolves all registered services of a specified type T using the given resolver and context.
func WithInstance ¶
func WithInstance[T any](instance T) types.ResolverOptionsFunc
WithInstance Creates a ResolverOptionsFunc that registers a specific instance of a type T with a service registry to be resolved as a singleton.
Types ¶
type NamedServiceResolverActivatorFunc ¶
NamedServiceResolverActivatorFunc defines a function for resolving named services.
func CreateNamedServiceResolverActivatorFunc ¶
func CreateNamedServiceResolverActivatorFunc[T any]() NamedServiceResolverActivatorFunc[T]
CreateNamedServiceResolverActivatorFunc creates a NamedServiceResolverActivatorFunc for resolving named services.