Documentation ¶
Index ¶
- func OptAutoload(enabled bool) scOption
- func OptLoadTimeout(timeout time.Duration) scOption
- func WithAutoload(enabled bool) scOption
- func WithLoadTimeout(timeout time.Duration) scOption
- 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 ...scOption) (Config, error)
- func (p *ConfigProvider) SubscribeForServiceConfig(ctx context.Context, serviceName string, opts ...subOption) (chan Config, error)
- type ConfigsLoader
- type ConfigsStorage
- type ErrServiceConfigNotFound
- type ErrSourceIsNotUnique
- type ErrSourceNotFound
- type LoadError
- type LoadResult
- type Loader
- type MapConfig
- type Source
- type SourcesStorage
- type SyncedConfigsStorage
- type SyncedSourcesStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OptAutoload ¶ added in v0.2.0
func OptAutoload(enabled bool) scOption
"Opt" prefix is deprecated, will be removed at v0.3 TODO: remove "Opt" prefixed options
func OptLoadTimeout ¶ added in v0.2.0
func WithAutoload ¶ added in v0.2.1
func WithAutoload(enabled bool) scOption
WithAutoload provide ability to enable or disable autoload
func WithLoadTimeout ¶ added in v0.2.1
WithLoadTimeout provide ability to set load timeout
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 ...scOption) (Config, error)
ServiceConfig provide service config
func (*ConfigProvider) SubscribeForServiceConfig ¶
func (p *ConfigProvider) SubscribeForServiceConfig(ctx context.Context, serviceName string, opts ...subOption) (chan Config, error)
TODO: 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 Has(serviceName string) bool }
ConfigsStorage.
type ErrServiceConfigNotFound ¶ added in v0.2.0
type ErrServiceConfigNotFound struct {
ServiceName string
}
func (ErrServiceConfigNotFound) Error ¶ added in v0.2.0
func (e ErrServiceConfigNotFound) Error() string
Error.
type ErrSourceIsNotUnique ¶ added in v0.2.0
type ErrSourceIsNotUnique struct {
SourceID string
}
func (ErrSourceIsNotUnique) Error ¶ added in v0.2.0
func (e ErrSourceIsNotUnique) Error() string
Error.
type ErrSourceNotFound ¶ added in v0.2.0
type ErrSourceNotFound struct {
SourceID string
}
represents
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 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 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.
func (*SyncedConfigsStorage) Has ¶ added in v0.2.0
func (c *SyncedConfigsStorage) Has(serviceName string) bool
Has checks service config exist
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.