injecting

package
v1.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RefreshDefault = refreshState(iota) // Not refreshed yet
	Refreshing                          // Currently refreshing
	Refreshed                           // Successfully refreshed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgContext

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

ArgContext provides injection context for factory callables, exposing property access and bean lookup.

func NewArgContext

func NewArgContext(c *Injector, stack *Stack) *ArgContext

NewArgContext constructs a new ArgContext for a wiring operation.

func (*ArgContext) Bind

func (a *ArgContext) Bind(v reflect.Value, tag string) error

Bind binds a configuration property to a reflect.Value based on struct tag.

func (*ArgContext) Check

func (a *ArgContext) Check(c gs.Condition) (bool, error)

Check evaluates whether a condition matches in the current context.

func (*ArgContext) Find

func (a *ArgContext) Find(s gs.BeanSelector) ([]gs.CondBean, error)

Find returns beans satisfying a selector, as conditional beans.

func (*ArgContext) Has

func (a *ArgContext) Has(key string) bool

Has checks whether a configuration key is present.

func (*ArgContext) Prop

func (a *ArgContext) Prop(key string, def ...string) string

Prop retrieves a property value, with optional default.

func (*ArgContext) Wire

func (a *ArgContext) Wire(v reflect.Value, tag string) error

Wire performs autowiring on a reflect.Value, using the given tag.

type BeanRuntime

type BeanRuntime interface {
	Name() string               // The name of the bean
	Type() reflect.Type         // The type of the bean
	Value() reflect.Value       // The value of the bean
	Interface() any             // The Underlying value
	Callable() *gs_arg.Callable // Constructor, if any
	Status() gs_bean.BeanStatus // Lifecycle status
	String() string             // String representation
}

BeanRuntime defines an interface for runtime bean information.

type Injecting

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

Injecting defines a bean injection container.

func New

func New(p conf.Properties) *Injecting

New creates a new Injecting instance.

func (*Injecting) Close

func (c *Injecting) Close()

Close closes the container and cleans up resources.

func (*Injecting) Refresh

func (c *Injecting) Refresh(beans []*gs_bean.BeanDefinition) (err error)

Refresh loads and wires all provided bean definitions.

func (*Injecting) RefreshProperties

func (c *Injecting) RefreshProperties(p conf.Properties) error

RefreshProperties refreshes the properties of the container.

func (*Injecting) Wire

func (c *Injecting) Wire(obj any) error

Wire injects dependencies into the given object.

type Injector

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

Injector handles the core autowiring and bean creation logic.

type LazyField

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

LazyField represents a lazy-injected field with metadata.

type Stack

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

Stack tracks bean wiring context: current beans, lazy fields, and destroyers.

func NewStack

func NewStack() *Stack

NewStack initializes a fresh wiring stack for a new Refresh or Wire call.

func (*Stack) Path

func (s *Stack) Path() (path string)

Path builds a readable representation of the wiring stack path for errors.

type WireTag

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

WireTag represents a parsed injection tag in the format TypeName:BeanName?.

func (WireTag) String

func (tag WireTag) String() string

String converts a wireTag back to its string representation.

Jump to

Keyboard shortcuts

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