Documentation
¶
Index ¶
- Variables
- func HasInstance(cluster ClusterConfig, name string) bool
- func Instances(cluster ClusterConfig) []string
- type ClusterConfig
- type Collector
- type Config
- func (c *Config) Elems(path []string) ([]string, error)
- func (c *Config) ForEach(path []string, fun func(path []string, value any))
- func (c *Config) Get(path []string) (any, error)
- func (c *Config) Merge(low *Config)
- func (c *Config) Set(path []string, value any) error
- func (c *Config) String() string
- func (c *Config) UnmarshalYAML(unmarshal func(any) error) error
- type EnvCollector
- type FileCollector
- type GroupConfig
- type InstanceConfig
- type ReplicasetConfig
- type YamlCollector
Constants ¶
This section is empty.
Variables ¶
var ConfigEnvPaths = [][]string{}/* 123 elements not displayed */
Functions ¶
func HasInstance ¶
func HasInstance(cluster ClusterConfig, name string) bool
HasInstance returns true if an instance with the name exists in the config.
func Instances ¶
func Instances(cluster ClusterConfig) []string
Instances returns a list of instance names from the cluster config.
Types ¶
type ClusterConfig ¶
type ClusterConfig struct {
// RawConfig is a configuration of the global scope.
RawConfig *Config `yaml:"-"`
// Groups are parsed configurations per a group.
Groups map[string]GroupConfig
}
ClusterConfig describes a cluster configuration.
func GetClusterConfig ¶
func GetClusterConfig(path string) (ClusterConfig, error)
GetClusterConfig returns a cluster configuration loaded from a path to a config file. It uses a a config file, etcd and default environment variables as sources. The function returns a cluster config as is, without merging of settings from scopes: global, group, replicaset, instance.
func MakeClusterConfig ¶
func MakeClusterConfig(config *Config) (ClusterConfig, error)
MakeClusterConfig creates a ClusterConfig object from a configuration.
func (*ClusterConfig) UnmarshalYAML ¶
func (c *ClusterConfig) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML helps to unmarshal a ClusterConfig object from YAML.
type Collector ¶
type Collector interface {
// Collect collects a configuration or returns an error.
Collect() (*Config, error)
}
Collector interface must be implemented by a configuration source collector.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a container for deserialized configuration.
func Instantiate ¶
func Instantiate(cluster ClusterConfig, name string) *Config
Instantiate returns a fetched instance config from the cluster config. If the cluster config has the instance then it returns a merged config of the instance from scopes: global, group, replicaset, instance. If the cluster config has not the instance then it returns a global scope of the cluster config.
func (*Config) Merge ¶
Merge merges a configuration to the current. The outside configuration has a low priority.
type EnvCollector ¶
type EnvCollector struct {
// contains filtered or unexported fields
}
EnvCollector collects a configuration from environment variables.
func NewEnvCollector ¶
func NewEnvCollector(formatter func(path []string) string) EnvCollector
NewEnvCollector creates a new EnvCollector. A path to an environment variable format function must be specified.
func (EnvCollector) Collect ¶
func (c EnvCollector) Collect() (*Config, error)
Collect collects a configuration from environment variables.
type FileCollector ¶
type FileCollector struct {
// contains filtered or unexported fields
}
FileCollector collects data from a YAML file.
func NewFileCollector ¶
func NewFileCollector(path string) FileCollector
NewFileCollector create a new file collector for a path.
func (FileCollector) Collect ¶
func (c FileCollector) Collect() (*Config, error)
Collect collects a configuration from a file located at a specified path.
type GroupConfig ¶
type GroupConfig struct {
// RawConfig is a raw configuration of the group scope.
RawConfig *Config `yaml:"-"`
// Replicasets are parsed configurations per a replicaset.
Replicasets map[string]ReplicasetConfig
}
GroupConfig describes a group configuration.
func (*GroupConfig) UnmarshalYAML ¶
func (c *GroupConfig) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML helps to unmarshal a GroupConfig object from YAML.
type InstanceConfig ¶
type InstanceConfig struct {
// RawConfig is a raw configuration of the instance scope.
RawConfig *Config `yaml:"-"`
}
InstanceConfig describes an instance configuration.
func GetInstanceConfig ¶
func GetInstanceConfig(cluster ClusterConfig, instance string) (InstanceConfig, error)
GetInstanceConfig returns a full configuration for an instance with the name from a cluster config. It merges the configuration from all configured sources and scopes: environment, global, group, replicaset, instance.
func MakeInstanceConfig ¶
func MakeInstanceConfig(config *Config) (InstanceConfig, error)
MakeInstanceConfig creates an InstanceConfig object from a configuration.
func (*InstanceConfig) UnmarshalYAML ¶
func (c *InstanceConfig) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML helps to unmarshal an InstanceConfig object from YAML.
type ReplicasetConfig ¶
type ReplicasetConfig struct {
// RawConfig is a raw configuration of the replicaset scope.
RawConfig *Config `yaml:"-"`
// Instances are configurations at an instance scope.
Instances map[string]InstanceConfig
}
ReplicasetConfig describes a replicaset configuration.
func (*ReplicasetConfig) UnmarshalYAML ¶
func (c *ReplicasetConfig) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML helps to unmarshal a ReplicasetConfig object from YAML.
type YamlCollector ¶
type YamlCollector struct {
// contains filtered or unexported fields
}
YamlCollector collects a configuration from YAML data.
func NewYamlCollector ¶
func NewYamlCollector(data []byte) YamlCollector
NewYamlCollector create a new YAML collector.
func (YamlCollector) Collect ¶
func (c YamlCollector) Collect() (*Config, error)
Collect collects a configuration from YAML data.