mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-29 11:52:00 +08:00

- Introduces `Config`, `ConfigFactory`, `ProviderFactory`, and `Service` interfaces in `config.go`, `provider.go`, and `service.go`. - Implements `NamedMap` for managing named factories in `named.go`. - Adds `ProviderSettings` and `ScopedProviderSettings` for managing provider settings in `setting.go`.
38 lines
948 B
Go
38 lines
948 B
Go
package factory
|
|
|
|
// Config is an interface that defines methods for creating and validating configurations.
|
|
type Config interface {
|
|
// Validate the configuration and returns an error if invalid.
|
|
Validate() error
|
|
}
|
|
|
|
// NewConfigFunc is a function that creates a new config.
|
|
type NewConfigFunc func() Config
|
|
|
|
// ConfigFactory is a factory that creates a new config.
|
|
type ConfigFactory interface {
|
|
Named
|
|
New() Config
|
|
}
|
|
|
|
// configFactory is a factory that implements the ConfigFactory interface.
|
|
type configFactory struct {
|
|
name Name
|
|
newConfigFunc NewConfigFunc
|
|
}
|
|
|
|
// Name returns the name of the factory.
|
|
func (factory *configFactory) Name() Name {
|
|
return factory.name
|
|
}
|
|
|
|
// New creates a new config.
|
|
func (factory *configFactory) New() Config {
|
|
return factory.newConfigFunc()
|
|
}
|
|
|
|
// Creates a new config factory.
|
|
func NewConfigFactory(name Name, f NewConfigFunc) ConfigFactory {
|
|
return &configFactory{name: name, newConfigFunc: f}
|
|
}
|