component

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HighestPriority = math.MinInt
	LowestPriority  = math.MaxInt
)
View Source
const (
	SingletonScope = "singleton"
	PrototypeScope = "prototype"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	// contains filtered or unexported fields
}

func List

func List(filters ...filter.Filter) []*Component

func (*Component) Conditions

func (c *Component) Conditions() []Condition

func (*Component) Definition

func (c *Component) Definition() *Definition

type Condition

type Condition interface {
	MatchesCondition(ctx ConditionContext) bool
}

type ConditionContext

type ConditionContext struct {
	// contains filtered or unexported fields
}

func (ConditionContext) Container

func (c ConditionContext) Container() Container

func (ConditionContext) Deadline

func (c ConditionContext) Deadline() (deadline time.Time, ok bool)

func (ConditionContext) Done

func (c ConditionContext) Done() <-chan struct{}

func (ConditionContext) Err

func (c ConditionContext) Err() error

func (ConditionContext) Value

func (c ConditionContext) Value(key any) any

type ConditionEvaluator

type ConditionEvaluator struct {
	// contains filtered or unexported fields
}

func NewConditionEvaluator

func NewConditionEvaluator(container Container) ConditionEvaluator

func (ConditionEvaluator) Evaluate

func (e ConditionEvaluator) Evaluate(ctx context.Context, conditions []Condition) bool

type Constructor

type Constructor any

type ConstructorArgument

type ConstructorArgument struct {
	// contains filtered or unexported fields
}

func (ConstructorArgument) ArgumentIndex

func (a ConstructorArgument) ArgumentIndex() int

func (ConstructorArgument) IsOptional

func (a ConstructorArgument) IsOptional() bool

func (ConstructorArgument) Name

func (a ConstructorArgument) Name() string

func (ConstructorArgument) Type

type Container

type Container interface {
	GetObject(ctx context.Context, filters ...filter.Filter) (any, error)
	ListObjects(ctx context.Context, filters ...filter.Filter) []any
	ContainsObject(name string) bool
	IsSingleton(name string) bool
	IsPrototype(name string) bool
	Definitions() DefinitionRegistry
	Singletons() SingletonRegistry
	RegisterScope(name string, scope Scope) error
	ScopeNames() []string
	FindScope(name string) (Scope, error)
	AddObjectProcessor(processor ObjectProcessor) error
	ObjectProcessorCount() int
}

type Definition

type Definition struct {
	// contains filtered or unexported fields
}

func MakeDefinition

func MakeDefinition(constructor Constructor, options ...Option) (*Definition, error)

func (*Definition) Constructor

func (d *Definition) Constructor() reflector.Function

func (*Definition) ConstructorArguments

func (d *Definition) ConstructorArguments() []*ConstructorArgument

func (*Definition) IsPrototype

func (d *Definition) IsPrototype() bool

func (*Definition) IsSingleton

func (d *Definition) IsSingleton() bool

func (*Definition) Name

func (d *Definition) Name() string

func (*Definition) Scope

func (d *Definition) Scope() string

func (*Definition) Type

func (d *Definition) Type() reflector.Type

type DefinitionLoader added in v0.0.17

type DefinitionLoader struct {
	// contains filtered or unexported fields
}

func NewDefinitionLoader added in v0.0.17

func NewDefinitionLoader(container Container) *DefinitionLoader

func (*DefinitionLoader) LoadDefinitions added in v0.0.17

func (l *DefinitionLoader) LoadDefinitions(ctx context.Context, components []*Component) error

type DefinitionNotFoundError

type DefinitionNotFoundError struct {
	// contains filtered or unexported fields
}

func (DefinitionNotFoundError) Error

func (e DefinitionNotFoundError) Error() string

type DefinitionRegistry

type DefinitionRegistry interface {
	Register(definition *Definition) error
	Remove(name string) error
	Contains(name string) bool
	Find(filters ...filter.Filter) (*Definition, error)
	FindFirst(filters ...filter.Filter) (*Definition, bool)
	List(filters ...filter.Filter) []*Definition
	Names() []string
	Count() int
}

type Initialization

type Initialization interface {
	DoInit(ctx context.Context) error
}

type ObjectContainer

type ObjectContainer struct {
	// contains filtered or unexported fields
}

func NewObjectContainer

func NewObjectContainer() *ObjectContainer

func (*ObjectContainer) AddObjectProcessor

func (c *ObjectContainer) AddObjectProcessor(processor ObjectProcessor) error

func (*ObjectContainer) ContainsObject

func (c *ObjectContainer) ContainsObject(name string) bool

func (*ObjectContainer) Definitions

func (c *ObjectContainer) Definitions() DefinitionRegistry

func (*ObjectContainer) FindScope

func (c *ObjectContainer) FindScope(name string) (Scope, error)

func (*ObjectContainer) GetObject

func (c *ObjectContainer) GetObject(ctx context.Context, filters ...filter.Filter) (any, error)

func (*ObjectContainer) IsPrototype

func (c *ObjectContainer) IsPrototype(name string) bool

func (*ObjectContainer) IsSingleton

func (c *ObjectContainer) IsSingleton(name string) bool

func (*ObjectContainer) ListObjects

func (c *ObjectContainer) ListObjects(ctx context.Context, filters ...filter.Filter) []any

func (*ObjectContainer) ObjectProcessorCount

func (c *ObjectContainer) ObjectProcessorCount() int

func (*ObjectContainer) RegisterScope

func (c *ObjectContainer) RegisterScope(name string, scope Scope) error

func (*ObjectContainer) ScopeNames

func (c *ObjectContainer) ScopeNames() []string

func (*ObjectContainer) Singletons

func (c *ObjectContainer) Singletons() SingletonRegistry

type ObjectDefinitionRegistry

type ObjectDefinitionRegistry struct {
	// contains filtered or unexported fields
}

func NewObjectDefinitionRegistry

func NewObjectDefinitionRegistry() *ObjectDefinitionRegistry

func (*ObjectDefinitionRegistry) Contains

func (r *ObjectDefinitionRegistry) Contains(name string) bool

func (*ObjectDefinitionRegistry) Count

func (r *ObjectDefinitionRegistry) Count() int

func (*ObjectDefinitionRegistry) Find

func (r *ObjectDefinitionRegistry) Find(filters ...filter.Filter) (*Definition, error)

func (*ObjectDefinitionRegistry) FindFirst

func (r *ObjectDefinitionRegistry) FindFirst(filters ...filter.Filter) (*Definition, bool)

func (*ObjectDefinitionRegistry) List

func (r *ObjectDefinitionRegistry) List(filters ...filter.Filter) []*Definition

func (*ObjectDefinitionRegistry) Names

func (r *ObjectDefinitionRegistry) Names() []string

func (*ObjectDefinitionRegistry) Register

func (r *ObjectDefinitionRegistry) Register(definition *Definition) error

func (*ObjectDefinitionRegistry) Remove

func (r *ObjectDefinitionRegistry) Remove(name string) error

type ObjectNotFoundError

type ObjectNotFoundError struct {
	// contains filtered or unexported fields
}

func (ObjectNotFoundError) Error

func (e ObjectNotFoundError) Error() string

type ObjectProcessor

type ObjectProcessor interface {
	ProcessBeforeInit(ctx context.Context, object any) (any, error)
	ProcessAfterInit(ctx context.Context, object any) (any, error)
}

type ObjectProvider

type ObjectProvider func(ctx context.Context) (any, error)

type Option

type Option func(definition *Definition) error

func Named

func Named(name string) Option

func Optional

func Optional[T any]() Option

func OptionalAt

func OptionalAt(index int) Option

func Qualifier

func Qualifier[T any](name string) Option

func QualifierAt

func QualifierAt(index int, name string) Option

func Scoped

func Scoped(scope string) Option

type Prioritized added in v0.0.17

type Prioritized interface {
	Priority() int
}

type Registration

type Registration struct {
	// contains filtered or unexported fields
}

func Register

func Register(constructor Constructor, options ...Option) Registration

func (Registration) ConditionalOn

func (r Registration) ConditionalOn(condition Condition) Registration

type Scope

type Scope interface {
	GetObject(ctx context.Context, name string, provider ObjectProvider) (any, error)
	RemoveObject(ctx context.Context, name string) (any, error)
}

type SingletonObjectRegistry

type SingletonObjectRegistry struct {
	// contains filtered or unexported fields
}

func NewSingletonObjectRegistry

func NewSingletonObjectRegistry() *SingletonObjectRegistry

func (*SingletonObjectRegistry) Contains

func (r *SingletonObjectRegistry) Contains(name string) bool

func (*SingletonObjectRegistry) Count

func (r *SingletonObjectRegistry) Count() int

func (*SingletonObjectRegistry) Find

func (r *SingletonObjectRegistry) Find(filters ...filter.Filter) (any, error)

func (*SingletonObjectRegistry) FindFirst

func (r *SingletonObjectRegistry) FindFirst(filters ...filter.Filter) (any, bool)

func (*SingletonObjectRegistry) List

func (r *SingletonObjectRegistry) List(filters ...filter.Filter) []any

func (*SingletonObjectRegistry) Names

func (r *SingletonObjectRegistry) Names() []string

func (*SingletonObjectRegistry) OrElseCreate

func (r *SingletonObjectRegistry) OrElseCreate(name string, provider ObjectProvider) (any, error)

func (*SingletonObjectRegistry) Register

func (r *SingletonObjectRegistry) Register(name string, object any) error

func (*SingletonObjectRegistry) Remove

func (r *SingletonObjectRegistry) Remove(name string) error

type SingletonRegistry

type SingletonRegistry interface {
	Register(name string, object any) error
	Remove(name string) error
	Find(filters ...filter.Filter) (any, error)
	FindFirst(filters ...filter.Filter) (any, bool)
	List(filters ...filter.Filter) []any
	OrElseCreate(name string, provider ObjectProvider) (any, error)
	Contains(name string) bool
	Names() []string
	Count() int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳