container

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContainer

func NewContainer() interfaces.Container

NewContainer creates a new, uninitialized container. Deprecated: Use NewBuilder for more flexible container initialization.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is a builder for creating and initializing a Container. It provides a fluent API for configuring and building a container instance.

func NewBuilder

func NewBuilder(componentFactories map[string]interfaces.ComponentFactory) *Builder

NewBuilder creates a new Builder instance. The builder can be used to configure and build a container with the provided config.

func (*Builder) Build

func (b *Builder) Build() (interfaces.Container, error)

Build initializes and returns the Container using the provided config. It returns the container and any error that occurred during initialization.

func (*Builder) Initialize

func (b *Builder) Initialize(cfg interfaces.Config) error

Initialize consumes the configuration and initializes all core and generic components. This is the main logic hub for component creation.

func (*Builder) Logger

func (b *Builder) Logger() log.Logger

func (*Builder) MustBuild

func (b *Builder) MustBuild() interfaces.Container

MustBuild is like Build but panics if an error occurs. This is useful for initialization code that should fail fast.

func (*Builder) WithComponent

func (b *Builder) WithComponent(name string, component interface{}) *Builder

WithComponent adds a pre-initialized component to the container.

func (*Builder) WithConfig

func (b *Builder) WithConfig(cfg interfaces.StructuredConfig) *Builder

WithConfig sets the configuration that will be used when building the container.

func (*Builder) WithFactory

func (b *Builder) WithFactory(name string, factory interfaces.ComponentFactory) *Builder

WithFactory registers a component factory with the container.

func (*Builder) WithLogger

func (b *Builder) WithLogger(logger log.Logger) *Builder

WithLogger sets a custom logger for the container.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL