resolving

package
v0.0.0-...-8c94d94 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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

func NewScopedContext(ctx context.Context) context.Context

NewScopedContext creates a new context with an associated service instance map, useful for managing service lifetimes within scope.

func ResolveRequiredService

func ResolveRequiredService[T any](resolver types.Resolver, ctx context.Context) (T, error)

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

func ResolveRequiredServices[T any](resolver types.Resolver, ctx context.Context) ([]T, error)

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

type NamedServiceResolverActivatorFunc[T any] func(types.Resolver) func(string) (T, error)

NamedServiceResolverActivatorFunc defines a function for resolving named services.

func CreateNamedServiceResolverActivatorFunc

func CreateNamedServiceResolverActivatorFunc[T any]() NamedServiceResolverActivatorFunc[T]

CreateNamedServiceResolverActivatorFunc creates a NamedServiceResolverActivatorFunc for resolving named services.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL