#
registration
import "github.com/matzefriedrich/parsley/pkg/registration"
#
Index
Constants Variables func CreateServiceActivatorFrom[T any](instance T) (func() T, error) func CreateServiceRegistration(activatorFunc any, lifetimeScope types.LifetimeScope) (types.ServiceRegistrationSetup, error) func NewDependencyInfo(registration types.ServiceRegistration, instance interface{}, consumer types.DependencyInfo) types.DependencyInfo func NewMultiRegistryAccessor(registries ...types.ServiceRegistryAccessor) types.ServiceRegistryAccessor func NewServiceRegistrationList(sequence core.ServiceIdSequence) types.ServiceRegistrationList func NewServiceRegistry() types.ServiceRegistry func RegisterInstance[T any](registry types.ServiceRegistry, instance T) error func RegisterScoped(registry SupportsRegisterActivatorFunc, activatorFunc ...any) error func RegisterSingleton(registry SupportsRegisterActivatorFunc, activatorFunc ...any) error func RegisterTransient(registry SupportsRegisterActivatorFunc, activatorFunc ...any) error type NamedServiceRegistrationFunc func NamedServiceRegistration(name string, activatorFunc any, scope types.LifetimeScope) NamedServiceRegistrationFunc
type SupportsRegisterActivatorFunc type Validator func NewServiceRegistrationsValidator() Validator
#
Constants
const (
ErrorFailedToRetrieveServiceRegistrations = "failed to retrieve service registrations"
ErrorRegistryMissesRequiredServiceRegistrations = "the registry misses required service registrations"
ErrorCircularServiceRegistrationDetected = "circular service registration detected"
)
#
Variables
var (
// ErrFailedToRetrieveServiceRegistrations signifies an error encountered while attempting to retrieve service registrations.
ErrFailedToRetrieveServiceRegistrations = types.NewRegistryError(ErrorFailedToRetrieveServiceRegistrations)
// ErrRegistryMissesRequiredServiceRegistrations indicates that required service registrations are missing.
ErrRegistryMissesRequiredServiceRegistrations = types.NewRegistryError(ErrorRegistryMissesRequiredServiceRegistrations)
// ErrCircularServiceRegistrationDetected signifies that a circular service registration was encountered.
ErrCircularServiceRegistrationDetected = types.NewResolverError(ErrorCircularServiceRegistrationDetected)
)
#
func CreateServiceActivatorFrom
func CreateServiceActivatorFrom[T any](instance T) (func() T, error)
CreateServiceActivatorFrom creates a service activator function for a given instance of type T.
#
func CreateServiceRegistration
func CreateServiceRegistration(activatorFunc any, lifetimeScope types.LifetimeScope) (types.ServiceRegistrationSetup, error)
CreateServiceRegistration creates a service registration instance from the given activator function and lifetime scope.
#
func NewDependencyInfo
func NewDependencyInfo(registration types.ServiceRegistration, instance interface{}, consumer types.DependencyInfo) types.DependencyInfo
NewDependencyInfo creates a new instance of types.DependencyInfo with the provided service registration, instance, and parent dependency.
#
func NewMultiRegistryAccessor
func NewMultiRegistryAccessor(registries ...types.ServiceRegistryAccessor) types.ServiceRegistryAccessor
NewMultiRegistryAccessor creates a new ServiceRegistryAccessor that aggregates multiple registries.
#
func NewServiceRegistrationList
func NewServiceRegistrationList(sequence core.ServiceIdSequence) types.ServiceRegistrationList
NewServiceRegistrationList creates a new service registration list instance.
#
func NewServiceRegistry
func NewServiceRegistry() types.ServiceRegistry
NewServiceRegistry creates a new types.ServiceRegistry instance.
#
func RegisterInstance
func RegisterInstance[T any](registry types.ServiceRegistry, instance T) error
RegisterInstance registers an instance of type T. A registered instance behaves like a service registration with a singleton lifetime scope.
#
func RegisterScoped
func RegisterScoped(registry SupportsRegisterActivatorFunc, activatorFunc ...any) error
RegisterScoped registers services with a scoped lifetime in the provided service registry.
#
func RegisterSingleton
func RegisterSingleton(registry SupportsRegisterActivatorFunc, activatorFunc ...any) error
RegisterSingleton registers services with a singleton lifetime in the provided service registry.
#
func RegisterTransient
func RegisterTransient(registry SupportsRegisterActivatorFunc, activatorFunc ...any) error
RegisterTransient registers services with a transient lifetime in the provided service registry.
#
type NamedServiceRegistrationFunc
NamedServiceRegistrationFunc defines a function that returns a service name, its activator function, and its lifetime scope. This type supports the internal infrastructure.
type NamedServiceRegistrationFunc func() (name string, activatorFunc any, scope types.LifetimeScope)
#
func NamedServiceRegistration
func NamedServiceRegistration(name string, activatorFunc any, scope types.LifetimeScope) NamedServiceRegistrationFunc
NamedServiceRegistration registers a service with a specified name, activator function, and lifetime scope.
#
type SupportsRegisterActivatorFunc
SupportsRegisterActivatorFunc allows the registration of activator functions with different lifetime scopes.
type SupportsRegisterActivatorFunc interface {
Register(activatorFunc any, scope types.LifetimeScope) error
}
#
type Validator
Validator defines an interface to validate service registries..
type Validator interface {
// Validate checks the provided ServiceRegistry for missing, invalid, or circular service dependencies. Returns an error if any issues are found.
Validate(registry types.ServiceRegistry) error
}
#
func NewServiceRegistrationsValidator
func NewServiceRegistrationsValidator() Validator
NewServiceRegistrationsValidator creates a new Validator instance.