MCPcopy Create free account
hub / github.com/codnect/procyon / initialize

Method initialize

component/container.go:626–641  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
626func (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.

Callers 1

createInstanceMethod · 0.95

Calls 3

applyPreProcessorsMethod · 0.95
applyPostProcessorsMethod · 0.95
InitMethod · 0.65

Tested by

no test coverage detected