Shutdown iterates through every CloserProvider registered in the container, and calls them in the reversed order of registration.
()
| 381 | // Shutdown iterates through every CloserProvider registered in the container, |
| 382 | // and calls them in the reversed order of registration. |
| 383 | func (c *C) Shutdown() { |
| 384 | modules := c.Modules() |
| 385 | for i := range modules { |
| 386 | if closer, ok := modules[len(modules)-i-1].(CloserProvider); ok { |
| 387 | closer.ProvideCloser() |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | // AddModuleFunc add the module after Invoking its constructor. Clean up |
| 393 | // functions and errors are handled automatically. |