-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathengine.go
37 lines (29 loc) · 1.02 KB
/
engine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package di
type ServiceAccessor func(*ContainerEngineScope) (any, error)
type ContainerEngine interface {
RealizeService(CallSite) (ServiceAccessor, error)
}
type containerEngine struct {
container *container
}
func (engine *containerEngine) RealizeService(callSite CallSite) (ServiceAccessor, error) {
return func(scope *ContainerEngineScope) (any, error) {
return CallSiteResolverInstance.Resolve(callSite, scope)
}, nil
}
// func (engine *containerEngine) RealizeService(callSite CallSite) (ServiceAccessor, error) {
// callCount := uint32(0)
// return func(scope *ContainerEngineScope) (any, error) {
// result, err := CallSiteResolverInstance.Resolve(callSite, scope)
// if callCount < 2 && atomic.AddUint32(&callCount, 1) == 2 {
// go func(sp *container) {
// // TODO: replace service accessor
// // sp.ReplaceServiceAccessor(accessor)
// }(engine.container)
// }
// return result, err
// }, nil
// }
func newContainerEngine(c *container) ContainerEngine {
return &containerEngine{container: c}
}