right now life cycle hook can only be set when build a container as below
`injector := do.NewWithOpts(&do.InjectorOpts{
HookAfterRegistration: func(injector do.Injector, serviceName string) {
fmt.Printf("Service registered: %s\n", serviceName)
},
HookAfterShutdown: func(injector do.Injector, serviceName string) {
fmt.Printf("Service stopped: %s\n", serviceName)
},
my case is that I am using do as DI container build some basic infra in the group for other projects. it's obvious that other teams(projects) also need hooks for project specific design. I export the DI but they can not register hook.
proposal:
if HookAfterRegistration and HookAfterShutdown are slcie of functions and di expose a new method to add a new hook method then it will work in my case
of course there is gotcha: this new added method which for adding hook will throw error when the DI is not emtpy
right now life cycle hook can only be set when build a container as below `injector := do.NewWithOpts(&do.InjectorOpts{ HookAfterRegistration: func(injector do.Injector, serviceName string) { fmt.Printf("Service registered: %s\n", serviceName) }, HookAfterShutdown: func(injector do.Injector, serviceName string) { fmt.Printf("Service stopped: %s\n", serviceName) },
})`
my case is that I am using do as DI container build some basic infra in the group for other projects. it's obvious that other teams(projects) also need hooks for project specific design. I export the DI but they can not register hook.
proposal: if HookAfterRegistration and HookAfterShutdown are slcie of functions and di expose a new method to add a new hook method then it will work in my case
of course there is gotcha: this new added method which for adding hook will throw error when the DI is not emtpy
thank you!