Documentation
¶
Index ¶
- Constants
- Variables
- func NewDependencyError(msg string) error
- func NewReflectionError(msg string, initializers ...ParsleyErrorFunc) error
- func NewRegistryError(msg string, initializers ...ParsleyErrorFunc) error
- func NewResolverError(msg string, initializers ...ParsleyErrorFunc) error
- type DependencyError
- type DependencyInfo
- type FunctionInfo
- type FunctionParameterInfo
- type LifetimeScope
- type ModuleFunc
- type NamedService
- type ParsleyAggregateError
- type ParsleyError
- type ParsleyErrorFunc
- type ParsleyErrorWithServiceTypeName
- type RegistrationConfigurationFunc
- type Resolver
- type ResolverError
- type ResolverOptionsFunc
- type ServiceRegistration
- type ServiceRegistrationList
- type ServiceRegistrationSetup
- type ServiceRegistry
- type ServiceRegistryAccessor
- type ServiceType
Constants ¶
View Source
const ( ErrorRequiresFunctionValue = "the given value is not function" ErrorCannotRegisterModule = "failed to register module" ErrorTypeAlreadyRegistered = "type already registered" ErrorServiceAlreadyLinkedWithAnotherList = "service already linked with another list" )
View Source
const ( ErrorServiceTypeNotRegistered = "service type is not registered" ErrorRequiredServiceNotRegistered = "required service type is not registered" ErrorCannotResolveService = "cannot resolve service" ErrorAmbiguousServiceInstancesResolved = "the resolve operation resulted in multiple service instances" ErrorActivatorFunctionInvalidReturnType = "activator function has an invalid return type" ErrorCircularDependencyDetected = "circular dependency detected" ErrorCannotBuildDependencyGraph = "failed to build dependency graph" ErrorInstanceCannotBeNil = "instance cannot be nil" ErrorServiceTypeMustBeInterface = "service type must be an interface" ErrorCannotRegisterTypeWithResolverOptions = "cannot register type with resolver options" )
View Source
const (
ErrorInstanceAlreadySet = "instance already set"
)
Variables ¶
View Source
var ( ErrRequiresFunctionValue = errors.New(ErrorRequiresFunctionValue) ErrCannotRegisterModule = errors.New(ErrorCannotRegisterModule) ErrTypeAlreadyRegistered = errors.New(ErrorTypeAlreadyRegistered) )
View Source
var ( ErrServiceTypeNotRegistered = errors.New(ErrorServiceTypeNotRegistered) ErrActivatorFunctionInvalidReturnType = errors.New(ErrorCannotResolveService) ErrCannotBuildDependencyGraph = errors.New(ErrorCannotBuildDependencyGraph) ErrCircularDependencyDetected = errors.New(ErrorCircularDependencyDetected) ErrInstanceCannotBeNil = errors.New(ErrorInstanceCannotBeNil) ErrServiceTypeMustBeInterface = errors.New(ErrorServiceTypeMustBeInterface) ErrCannotRegisterTypeWithResolverOptions = errors.New(ErrorCannotRegisterTypeWithResolverOptions) )
View Source
var (
ErrInstanceAlreadySet = errors.New(ErrorInstanceAlreadySet)
)
Functions ¶
func NewDependencyError ¶ added in v0.4.0
func NewReflectionError ¶ added in v0.6.1
func NewReflectionError(msg string, initializers ...ParsleyErrorFunc) error
func NewRegistryError ¶
func NewRegistryError(msg string, initializers ...ParsleyErrorFunc) error
func NewResolverError ¶
func NewResolverError(msg string, initializers ...ParsleyErrorFunc) error
Types ¶
type DependencyError ¶ added in v0.4.0
type DependencyError struct {
ParsleyError
}
type DependencyInfo ¶
type DependencyInfo interface {
AddRequiredServiceInfo(child DependencyInfo)
CreateInstance() (interface{}, error)
Consumer() DependencyInfo
HasInstance() bool
Instance() interface{}
Registration() ServiceRegistration
RequiredServiceTypes() []ServiceType
RequiredServices() ([]interface{}, error)
ServiceTypeName() string
SetInstance(instance interface{}) error
}
type FunctionInfo ¶
type FunctionInfo interface {
fmt.Stringer
Name() string
Parameters() []FunctionParameterInfo
ReturnType() ServiceType
ParameterTypes() []ServiceType
}
type FunctionParameterInfo ¶ added in v0.6.1
type FunctionParameterInfo interface {
fmt.Stringer
Type() ServiceType
}
type LifetimeScope ¶
type LifetimeScope uint
const ( LifetimeTransient LifetimeScope = iota LifetimeScoped LifetimeSingleton )
type ModuleFunc ¶ added in v0.3.0
type ModuleFunc func(registry ServiceRegistry) error
type NamedService ¶ added in v0.6.0
type ParsleyAggregateError ¶ added in v0.6.0
type ParsleyAggregateError struct {
// contains filtered or unexported fields
}
func (ParsleyAggregateError) Error ¶ added in v0.6.0
func (f ParsleyAggregateError) Error() string
func (ParsleyAggregateError) Is ¶ added in v0.6.0
func (f ParsleyAggregateError) Is(err error) bool
type ParsleyError ¶ added in v0.2.0
type ParsleyError struct {
// contains filtered or unexported fields
}
func (ParsleyError) Error ¶ added in v0.2.0
func (f ParsleyError) Error() string
func (ParsleyError) Is ¶ added in v0.2.0
func (f ParsleyError) Is(err error) bool
func (ParsleyError) Unwrap ¶ added in v0.2.0
func (f ParsleyError) Unwrap() error
type ParsleyErrorFunc ¶ added in v0.2.0
type ParsleyErrorFunc func(e error)
func ForServiceType ¶
func ForServiceType(serviceType string) ParsleyErrorFunc
func WithAggregatedCause ¶ added in v0.6.0
func WithAggregatedCause(errs ...error) ParsleyErrorFunc
func WithCause ¶
func WithCause(err error) ParsleyErrorFunc
type ParsleyErrorWithServiceTypeName ¶ added in v0.2.0
type ParsleyErrorWithServiceTypeName interface {
ServiceTypeName(name string)
}
type RegistrationConfigurationFunc ¶
type RegistrationConfigurationFunc func(r ServiceRegistration)
type Resolver ¶
type Resolver interface {
Resolve(ctx context.Context, serviceType ServiceType) ([]interface{}, error)
ResolveWithOptions(ctx context.Context, serviceType ServiceType, options ...ResolverOptionsFunc) ([]interface{}, error)
}
type ResolverError ¶
type ResolverError struct {
ParsleyError
// contains filtered or unexported fields
}
func (*ResolverError) ServiceTypeName ¶
func (r *ResolverError) ServiceTypeName(name string)
type ResolverOptionsFunc ¶ added in v0.3.0
type ResolverOptionsFunc func(registry ServiceRegistry) error
type ServiceRegistration ¶
type ServiceRegistration interface {
Id() uint64
InvokeActivator(params ...interface{}) (interface{}, error)
IsSame(other ServiceRegistration) bool
LifetimeScope() LifetimeScope
RequiredServiceTypes() []ServiceType
ServiceType() ServiceType
}
type ServiceRegistrationList ¶ added in v0.5.0
type ServiceRegistrationList interface {
AddRegistration(registration ServiceRegistrationSetup) error
Id() uint64
Registrations() []ServiceRegistration
IsEmpty() bool
}
type ServiceRegistrationSetup ¶ added in v0.3.0
type ServiceRegistrationSetup interface {
ServiceRegistration
SetId(id uint64) error
}
type ServiceRegistry ¶
type ServiceRegistry interface {
ServiceRegistryAccessor
CreateLinkedRegistry() ServiceRegistry
CreateScope() ServiceRegistry
IsRegistered(serviceType ServiceType) bool
Register(activatorFunc any, scope LifetimeScope) error
RegisterModule(modules ...ModuleFunc) error
}
type ServiceRegistryAccessor ¶
type ServiceRegistryAccessor interface {
TryGetServiceRegistrations(serviceType ServiceType) (ServiceRegistrationList, bool)
TryGetSingleServiceRegistration(serviceType ServiceType) (ServiceRegistration, bool)
}
type ServiceType ¶
func MakeServiceType ¶ added in v0.6.0
func MakeServiceType[T any]() ServiceType
func ServiceTypeFrom ¶ added in v0.6.0
func ServiceTypeFrom(t reflect.Type) ServiceType
Click to show internal directories.
Click to hide internal directories.