golazy.dev
–
golazy.dev
/
lazydeps
Index
|
Files
package lazydeps
import "golazy.dev/lazydeps"
Types
type Edge
type Edge struct {
From string
To string
}
type Func
type Func[T any] func(context.Context) (context.Context, T, error, context.CancelFunc)
type Graph
type Graph struct {
Nodes []string
Edges []Edge
}
type Ref
type Ref[T any] struct {
// contains filtered or unexported fields
}
func Service[T any]
func Service[T any](u *Scope, name string, fn Func[T]) (Ref[T], error)
func (r Ref[T]) Use
func (r Ref[T]) Use() T
type Scope
type Scope struct {
// contains filtered or unexported fields
}
func New
func New(ctx context.Context) *Scope
func (u *Scope) Context
func (u *Scope) Context() context.Context
func (u *Scope) Graph
func (u *Scope) Graph() Graph
func (u *Scope) SetContext
func (u *Scope) SetContext(ctx context.Context)
Package lazydeps records application dependency initialization and the dependency graph between services.
Applications receive a *Scope from lazyapp.Config.Dependencies and initialize shared services with Service. Service returns a typed Ref; calling Ref.Use inside another service initializer records that dependency edge and returns the wrapped service value.