initialize runs pre-processors, the Init method (if defined), and post-processors on the given instance, and it returns the fully initialized instance.
(ctx context.Context, instance any)
| 624 | // initialize runs pre-processors, the Init method (if defined), and post-processors |
| 625 | // on the given instance, and it returns the fully initialized instance. |
| 626 | func (d *DefaultContainer) initialize(ctx context.Context, instance any) (any, error) { |
| 627 | result, err := d.applyPreProcessors(ctx, instance) |
| 628 | if err != nil { |
| 629 | return nil, err |
| 630 | } |
| 631 | |
| 632 | if initializer, ok := instance.(Initializer); ok { |
| 633 | err = initializer.Init(ctx) |
| 634 | |
| 635 | if err != nil { |
| 636 | return nil, err |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | return d.applyPostProcessors(ctx, result) |
| 641 | } |
| 642 | |
| 643 | // applyPreProcessors executes all registered PreProcessor hooks on the instance. |
| 644 | // Returns the processed object or an error. |
no test coverage detected