config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Overview

Package config provides the functionality to read environment variables it has the power to read from a static config file or from a remote config server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoDotEnvProvider added in v1.0.0

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

func NewGoDotEnvProvider added in v1.0.0

func NewGoDotEnvProvider(l logger, configFolder string) *GoDotEnvProvider

NewGoDotEnvProvider creates a new instance of GoDotEnvProvider.

func (*GoDotEnvProvider) Get added in v1.0.0

func (g *GoDotEnvProvider) Get(key string) string

Get retrieves the value of an environment variable by its key.

func (*GoDotEnvProvider) GetOrDefault added in v1.0.0

func (g *GoDotEnvProvider) GetOrDefault(key, defaultValue string) string

GetOrDefault retrieves the value of an environment variable by its key, or returns a default value if the variable is not set.

type MockConfig added in v1.0.0

type MockConfig struct {
	Data map[string]string
}

MockConfig is a mock type that can be used for testing purposes wherever GoDotEnvProvider's methods are called

func (*MockConfig) Get added in v1.0.0

func (m *MockConfig) Get(key string) string

Get retrieves the value of a configuration parameter by its key. If the key exists in the map, it returns the corresponding value else it returns the empty string.

func (*MockConfig) GetOrDefault added in v1.0.0

func (m *MockConfig) GetOrDefault(key, defaultValue string) string

GetOrDefault retrieves the value of a configuration parameter by its key. If the key exists in the map, it returns the corresponding value else it returns the specified defaultValue.

type RemoteConfig added in v1.0.0

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

RemoteConfig holds the information about the remote config server to maintain and manage the configs for the application using a Remote Override Service

func NewRemoteConfigProvider added in v1.0.0

func NewRemoteConfigProvider(localConfig config, remoteConfigURL, appName string, logger logger) *RemoteConfig

NewRemoteConfigProvider creates a new instance of RemoteConfig for fetching remote configurations.

func (*RemoteConfig) Get added in v1.0.0

func (r *RemoteConfig) Get(key string) string

Get retrieves a configuration value by its key. It first checks the remote configurations, and if not found, falls back to the local configurations.

func (*RemoteConfig) GetOrDefault added in v1.0.0

func (r *RemoteConfig) GetOrDefault(key, defaultValue string) string

GetOrDefault retrieves a configuration value by its key and returns a default value if not found.

Jump to

Keyboard shortcuts

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