MCPcopy Create free account
hub / github.com/kataras/iris / newDependency

Function newDependency

hero/dependency.go:82–119  ·  view source on GitHub ↗
(
	dependency interface{},
	disablePayloadAutoBinding bool,
	enableStructDependents bool,
	matchDependency DependencyMatcher,
	funcDependencies ...*Dependency,
)

Source from the content-addressed store, hash-verified

80}
81
82func newDependency(
83 dependency interface{},
84 disablePayloadAutoBinding bool,
85 enableStructDependents bool,
86 matchDependency DependencyMatcher,
87 funcDependencies ...*Dependency,
88) *Dependency {
89 if dependency == nil {
90 panic(fmt.Sprintf("bad value: nil: %T", dependency))
91 }
92
93 if d, ok := dependency.(*Dependency); ok {
94 // already a *Dependency, do not continue (and most importatly do not call resolveDependency) .
95 return d
96 }
97
98 v := valueOf(dependency)
99 if !goodVal(v) {
100 panic(fmt.Sprintf("bad value: %#+v", dependency))
101 }
102
103 if matchDependency == nil {
104 matchDependency = DefaultDependencyMatcher
105 }
106
107 dest := &Dependency{
108 Source: newSource(v),
109 OriginalValue: dependency,
110 StructDependents: enableStructDependents,
111 }
112 dest.Match = ToDependencyMatchFunc(dest, matchDependency)
113
114 if !resolveDependency(v, disablePayloadAutoBinding, dest, funcDependencies...) {
115 panic(fmt.Sprintf("bad value: could not resolve a dependency from: %#+v", dependency))
116 }
117
118 return dest
119}
120
121// DependencyResolver func(v reflect.Value, dest *Dependency) bool
122// Resolver DependencyResolver

Callers 4

getBindingsForStructFunction · 0.85
NewDependencyFunction · 0.85
container.goFile · 0.85
RegisterMethod · 0.85

Calls 5

goodValFunction · 0.85
newSourceFunction · 0.85
ToDependencyMatchFuncFunction · 0.85
resolveDependencyFunction · 0.85
valueOfFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…