# resolving

import "github.com/matzefriedrich/parsley/pkg/resolving"

# Index

  • func Activate[T any](resolver types.Resolver, ctx context.Context, activatorFunc any, options ...types.ResolverOptionsFunc) (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
    • func CreateNamedServiceResolverActivatorFunc[T any]() NamedServiceResolverActivatorFunc[T]

# 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.

# type NamedServiceResolverActivatorFunc

NamedServiceResolverActivatorFunc defines a function for resolving named services.

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

# func CreateNamedServiceResolverActivatorFunc

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

CreateNamedServiceResolverActivatorFunc creates a NamedServiceResolverActivatorFunc for resolving named services.