Documentation
¶
Index ¶
- type Config
- type ConfigProvider
- func (p *ConfigProvider) AddSource(src Source) error
- func (p *ConfigProvider) Close(ctx context.Context)
- func (p *ConfigProvider) Load(ctx context.Context, services ...string) (loadErrors []LoadError)
- func (p *ConfigProvider) ServiceConfig(serviceName string, opts ...*Option) (Config, error)
- func (p *ConfigProvider) SubscribeForServiceConfig(ctx context.Context, serviceName string, opts ...*Option) (chan Config, error)
- type ConfigsLoader
- type ConfigsStorage
- type LoadError
- type LoadResult
- type Loader
- type MapConfig
- type Option
- type ServiceConfigStorageError
- type Source
- type SourceStorageError
- type SourceUniquenessError
- type SourcesStorage
- type SyncedConfigsStorage
- type SyncedSourcesStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface { // Get config value by key Get(key, defaultValue string) string // Set sets key value Set(key, value string) // Fmt renders `pattern` filling it with config values Fmt(pattern string) (string, error) }
Config
type ConfigProvider ¶
type ConfigProvider struct {
// contains filtered or unexported fields
}
Provider represents config provider.
func NewConfigProvider ¶
func NewConfigProvider(sourcesStorage SourcesStorage, configsStorage ConfigsStorage, loader Loader) *ConfigProvider
NewConfigProvider.
func NewDefaultConfigProvider ¶
func NewDefaultConfigProvider() *ConfigProvider
NewDefaultConfigProvider.
func (*ConfigProvider) AddSource ¶
func (p *ConfigProvider) AddSource(src Source) error
AddSource adds source to source storage.
func (*ConfigProvider) Load ¶
func (p *ConfigProvider) Load(ctx context.Context, services ...string) (loadErrors []LoadError)
Load updates inner services config cache.
func (*ConfigProvider) ServiceConfig ¶
func (p *ConfigProvider) ServiceConfig(serviceName string, opts ...*Option) (Config, error)
ServiceConfig provide service config from inner cache.
func (*ConfigProvider) SubscribeForServiceConfig ¶
func (p *ConfigProvider) SubscribeForServiceConfig(ctx context.Context, serviceName string, opts ...*Option) (chan Config, error)
SubscribeForServiceConfig creates a subscription for service config updates. Returns channel of Configs.
type ConfigsLoader ¶
type ConfigsLoader int
Loader represents.
func (*ConfigsLoader) Load ¶
func (cl *ConfigsLoader) Load(ctx context.Context, sources []Source, serviceNames []string) []LoadResult
Load loads configs from each source in parallel
type ConfigsStorage ¶
type ConfigsStorage interface { ByServiceName(serviceName string) (Config, error) Set(serviceName string, cfg Config) error }
ConfigsStorage.
type LoadResult ¶
LoadResult represents.
type Loader ¶
type Loader interface {
Load(ctx context.Context, sources []Source, serviceNames []string) []LoadResult
}
Loader.
type MapConfig ¶
type MapConfig struct {
// contains filtered or unexported fields
}
MapConfig represents map based config Implements Config interface.
type Option ¶
Option represents provision options options may affect subscription and config loading processes.
type ServiceConfigStorageError ¶
type ServiceConfigStorageError struct {
ServiceName string
}
type Source ¶
type Source interface { // Should return unique source identifier persistent for in all source lifetime ID() string // Load pull config for the list of service Load(ctx context.Context, serviceNames []string) error // Priority returns source priority Priority() int // ServiceConfig ServiceConfig(serviceName string) (Config, error) // Close closes connections Close(context.Context) }
Source.
type SourceUniquenessError ¶
type SourceUniquenessError struct {
SourceID string
}
type SourcesStorage ¶
type SourcesStorage interface { Append(src Source) error ByID(sourceID string) (Source, error) List() []Source }
SourceStorage
type SyncedConfigsStorage ¶
type SyncedConfigsStorage struct {
// contains filtered or unexported fields
}
ConfigsStorage represents configs map protected with mutex.
func NewSyncedConfigsStorage ¶
func NewSyncedConfigsStorage() *SyncedConfigsStorage
func (*SyncedConfigsStorage) ByServiceName ¶
func (c *SyncedConfigsStorage) ByServiceName(serviceName string) (Config, error)
Get receives configs by service name.
type SyncedSourcesStorage ¶
type SyncedSourcesStorage struct {
// contains filtered or unexported fields
}
syncedSources represents sources map protected with mutex.
func NewSyncedSourcesStorage ¶
func NewSyncedSourcesStorage() *SyncedSourcesStorage
NewSyncedSourcesStorage
func (*SyncedSourcesStorage) Append ¶
func (s *SyncedSourcesStorage) Append(src Source) error
Append
func (*SyncedSourcesStorage) ByID ¶
func (s *SyncedSourcesStorage) ByID(sourceID string) (Source, error)
ByID gets source by it's ID
func (*SyncedSourcesStorage) List ¶
func (s *SyncedSourcesStorage) List() []Source
List returns sources as a slice.