Documentation
¶
Index ¶
Constants ¶
const (
// TagServicePrefix is the prefix for desugared tag service IDs
TagServicePrefix = "__tagged_with."
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct {
Kind ArgumentKind
Type types.Type // Expected parameter type
// Value based on kind
Service *Service // For ServiceRef
Parameter *Parameter // For ParamRef
Tag *Tag // For Tagged
Literal LiteralValue // For Literal
Inner *Argument // For Spread (wraps another argument)
GoRef *GoRef // For GoRef
FieldAccess *FieldAccess // For FieldAccess
}
Argument is a resolved constructor argument.
type ArgumentKind ¶
type ArgumentKind int
ArgumentKind indicates the type of argument.
const ( LiteralArg ArgumentKind = iota ServiceRefArg ParamRefArg TaggedArg SpreadArg GoRefArg FieldAccessArg )
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs an IR Container from raw config.
func NewBuilder ¶
func NewBuilder(resolver TypeResolver) *Builder
NewBuilder creates a new IR builder.
type Constructor ¶
type Constructor struct {
Kind ConstructorKind
Func *types.Func // For FuncConstructor
Args []*Argument
// For method constructors
Receiver *Service // The service whose method is called
// For generic constructors
TypeArgs []types.Type // Resolved type arguments for generic functions
// Signature info
Params []types.Type
ResultType types.Type
ReturnsError bool
Variadic bool // True if function/method has variadic parameters
}
Constructor defines how a service is constructed.
func (*Constructor) Clone ¶
func (c *Constructor) Clone() *Constructor
type ConstructorKind ¶
type ConstructorKind int
ConstructorKind indicates the type of constructor.
const ( FuncConstructor ConstructorKind = iota MethodConstructor )
type Container ¶
type Container struct {
Services map[string]*Service
Parameters map[string]*Parameter
// contains filtered or unexported fields
}
Container is the fully resolved intermediate representation of a DI container.
func NewContainer ¶
func NewContainer() *Container
func (*Container) ParamGetters ¶
ParamGetters returns parameter getter methods needed by the container.
func (*Container) ServiceIDsPostOrder ¶
type FieldAccess ¶
type FieldAccess struct {
Service *Service // Non-nil for @service targets
GoRef *GoRef // Non-nil for !go: targets
FieldNames []string // Field chain, e.g. ["Database", "DSN"]
ResultType types.Type // Type of the final field
}
FieldAccess holds a field access expression on a service or Go symbol.
type LiteralType ¶
type LiteralType int
LiteralType indicates the type of literal.
const ( StringLiteral LiteralType = iota IntLiteral FloatLiteral BoolLiteral NullLiteral DurationLiteral )
type LiteralValue ¶
type LiteralValue struct {
Type LiteralType
Value interface{} // string, int64, float64, bool, or nil
}
LiteralValue holds a typed literal value.
type Parameter ¶
type Parameter struct {
Name string
Type types.Type
Value LiteralValue
}
Parameter is a resolved parameter definition.
func (*Parameter) GetterMethod ¶
GetterMethod returns the Provider method name for this parameter's type.
type Service ¶
type Service struct {
ID string
Type types.Type
// Construction
Constructor *Constructor
Alias *Service // If this is an alias, points to target service
// Lifecycle
Public bool
Autoconfigure bool
// Tags
Tags []*ServiceTag
// Computed
Dependencies []*Service // Direct dependencies (resolved)
}
Service is a fully resolved service definition.
type ServiceTag ¶
ServiceTag is a tag attached to a service.
type Tag ¶
type Tag struct {
Name string
ElementType types.Type
SortBy string
Public bool
Autoconfigure bool
Services []*Service // Services with this tag (sorted by priority)
}
Tag is a resolved tag definition.
type TypeResolver ¶
type TypeResolver interface {
LookupType(typeStr string) (types.Type, error)
LookupFunc(pkgPath, name string) (*types.Func, error)
LookupMethod(recv types.Type, name string) (*types.Func, error)
LookupVar(pkgPath, name string) (types.Object, error)
// InstantiateFunc instantiates a generic function with the given type arguments.
// Returns the instantiated signature. typeArgs are type strings to resolve.
InstantiateFunc(fn *types.Func, typeArgs []string) (*types.Signature, []types.Type, error)
}
TypeResolver resolves type strings to Go types.