di

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AppEnvDev = "dev"

Variables

View Source
var (
	ErrEmptyConfigPaths      = errors.New("config paths is set but empty after parsing")
	ErrNoConfigPathSet       = errors.New("neither config.file.paths nor config.file.path is set")
	ErrEtcdEndpointRequired  = errors.New("etcd endpoint is required when using etcd")
	ErrEmptyEtcdStaticPaths  = errors.New("etcd static paths is set but empty after parsing")
	ErrEmptyEtcdDynamicPaths = errors.New("etcd dynamic paths is set but empty after parsing")
)

Functions

This section is empty.

Types

type AbstractContainer

type AbstractContainer[C config, S serviceContainer] interface {
	GetConfig() *C
	GetServices() *S
}

type Config

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

func NewConfig

func NewConfig(ctx context.Context) (*Config, error)

func (*Config) GetAppEnv

func (c *Config) GetAppEnv() string

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

func (*Config) GetDuration

func (c *Config) GetDuration(key string) time.Duration

func (*Config) GetInt

func (c *Config) GetInt(key string) int

func (*Config) GetServiceName

func (c *Config) GetServiceName() string

func (*Config) GetStorage

func (c *Config) GetStorage() *viper.Viper

func (*Config) GetString

func (c *Config) GetString(key string) string

func (*Config) GetStringOrDefault

func (c *Config) GetStringOrDefault(key, defaultValue string) string

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string) []string

func (*Config) WatchBool

func (c *Config) WatchBool(key string) func() bool

func (*Config) WatchDuration

func (c *Config) WatchDuration(key string) func() time.Duration

func (*Config) WatchInt

func (c *Config) WatchInt(key string) func() int

func (*Config) WatchString

func (c *Config) WatchString(key string) func() string

func (*Config) WatchStringSlice

func (c *Config) WatchStringSlice(key string) func() []string

type Container

type Container[C config, S serviceContainer] struct {
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer[C config, S serviceContainer](
	ctx context.Context,
	initConfig func(context.Context) (C, error),
	initServices func(context.Context, C, ...ServiceOpts[S]) (S, error),
	opts ...ServiceOpts[S],
) (*Container[C, S], func() error, error)

func (*Container[C, S]) GetConfig

func (c *Container[C, S]) GetConfig() C

func (*Container[C, S]) GetServices

func (c *Container[C, S]) GetServices() S

type ServiceContainer

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

func NewServiceContainer

func NewServiceContainer() *ServiceContainer

func (*ServiceContainer) AddOnClose

func (s *ServiceContainer) AddOnClose(callback func() error)

type ServiceOpts

type ServiceOpts[S serviceContainer] func(*S)

Jump to

Keyboard shortcuts

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