Documentation
¶
Index ¶
- Constants
- Variables
- type ChangeHook
- type Config
- func (c *Config) AddLoader(loader Loader)
- func (c *Config) AddOnConfigChangeHook(hook ChangeHook)
- func (c *Config) Close(ctx context.Context) error
- func (c *Config) LogValue() slog.Value
- func (c *Config) OnChange(ctx context.Context) error
- func (c *Config) Reload(ctx context.Context) error
- func (c *Config) Watch(ctx context.Context) error
- type Connection
- type DefaultSettingsLoader
- func (l *DefaultSettingsLoader) Close() error
- func (l *DefaultSettingsLoader) Get(key string) (any, error)
- func (l *DefaultSettingsLoader) GetConfigKeys() ([]string, error)
- func (l *DefaultSettingsLoader) Load(_ Config) error
- func (l *DefaultSettingsLoader) Name() string
- func (l *DefaultSettingsLoader) Watch(_ context.Context, _ *Config, _ func(context.Context) error) error
- type EnvironmentValueLoader
- func (l *EnvironmentValueLoader) Close() error
- func (l *EnvironmentValueLoader) Get(key string) (any, error)
- func (l *EnvironmentValueLoader) GetConfigKeys() ([]string, error)
- func (l *EnvironmentValueLoader) Load(_ Config) error
- func (l *EnvironmentValueLoader) Name() string
- func (l *EnvironmentValueLoader) Watch(_ context.Context, _ *Config, _ func(context.Context) error) error
- type FileLoader
- func (l *FileLoader) Close() error
- func (l *FileLoader) Get(key string) (any, error)
- func (l *FileLoader) GetConfigKeys() ([]string, error)
- func (l *FileLoader) Load(_ Config) error
- func (l *FileLoader) Name() string
- func (l *FileLoader) Watch(ctx context.Context, _ *Config, onChange func(context.Context) error) error
- type LegacyLoader
- func (l *LegacyLoader) Close() error
- func (l *LegacyLoader) Get(key string) (any, error)
- func (l *LegacyLoader) GetConfigKeys() ([]string, error)
- func (l *LegacyLoader) Load(cfg Config) error
- func (l *LegacyLoader) Name() string
- func (l *LegacyLoader) Watch(ctx context.Context, _ *Config, onChange func(context.Context) error) error
- type Loader
- type SDKConfig
- type SecurityConfig
- type ServiceConfig
- type ServicesMap
- type UnsafeSecurityConfig
Constants ¶
const ( // DefaultUnsafeClockSkew is the default tolerated clock skew used when an unsafe override is not provided. DefaultUnsafeClockSkew = time.Minute )
const LoaderNameDefaultSettings = "default-settings"
const LoaderNameEnvironmentValue = "environment-value"
const LoaderNameFile = "config-file"
const LoaderNameLegacy = "legacy"
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ChangeHook ¶
type ChangeHook func(configServices ServicesMap) error
ChangeHook is a function invoked when the configuration changes.
type Config ¶
type Config struct {
// DevMode specifies whether the service is running in development mode.
DevMode bool `mapstructure:"dev_mode" json:"dev_mode"`
// DB represents the configuration settings for the database.
DB db.Config `mapstructure:"db" json:"db"`
// Server represents the configuration settings for the server.
Server server.Config `mapstructure:"server" json:"server"`
// Logger represents the configuration settings for the logger.
Logger logger.Config `mapstructure:"logger" json:"logger"`
// Mode specifies which services to run.
// By default, it runs all services.
Mode []string `mapstructure:"mode" json:"mode" default:"[\"all\"]"`
// Security holds platform-wide security overrides.
Security SecurityConfig `mapstructure:"security" json:"security"`
// SDKConfig represents the configuration settings for the SDK.
SDKConfig SDKConfig `mapstructure:"sdk_config" json:"sdk_config"`
// Services represents the configuration settings for the services.
Services ServicesMap `mapstructure:"services" json:"services"`
// contains filtered or unexported fields
}
Config represents the configuration settings for the service.
func (*Config) AddOnConfigChangeHook ¶
func (c *Config) AddOnConfigChangeHook(hook ChangeHook)
AddOnConfigChangeHook adds a hook to the list of hooks to call when the configuration changes.
func (*Config) LogValue ¶
LogValue returns a slog.Value representation of the config. We exclude logging service configuration as it may contain sensitive information.
func (*Config) OnChange ¶
OnChange invokes all registered onConfigChangeHooks after a configuration change.
type Connection ¶
type Connection struct {
// Endpoint is the URL of the platform or service.
Endpoint string `mapstructure:"endpoint" json:"endpoint"`
// Plaintext specifies whether the SDK should use plaintext communication.
Plaintext bool `mapstructure:"plaintext" json:"plaintext" default:"false" validate:"boolean"`
// Insecure specifies whether the SDK should use insecure TLS communication.
Insecure bool `mapstructure:"insecure" json:"insecure" default:"false" validate:"boolean"`
}
type DefaultSettingsLoader ¶ added in v0.10.0
type DefaultSettingsLoader struct {
KVMap map[string]any
// contains filtered or unexported fields
}
DefaultSettingsLoader implements Loader using Viper
func NewDefaultSettingsLoader ¶ added in v0.10.0
func NewDefaultSettingsLoader() (*DefaultSettingsLoader, error)
NewDefaultSettingsLoader creates a new Viper-based configuration loader to hold default config.
func (*DefaultSettingsLoader) Close ¶ added in v0.10.0
func (l *DefaultSettingsLoader) Close() error
func (*DefaultSettingsLoader) Get ¶ added in v0.10.0
func (l *DefaultSettingsLoader) Get(key string) (any, error)
Get fetches a particular config value by dot-delimited key from the source
func (*DefaultSettingsLoader) GetConfigKeys ¶ added in v0.10.0
func (l *DefaultSettingsLoader) GetConfigKeys() ([]string, error)
GetConfigKeys returns all the default configuration keys pulled from the Config struct.
func (*DefaultSettingsLoader) Load ¶ added in v0.10.0
func (l *DefaultSettingsLoader) Load(_ Config) error
Load loads the configuration into the provided struct
func (*DefaultSettingsLoader) Name ¶ added in v0.10.0
func (l *DefaultSettingsLoader) Name() string
type EnvironmentValueLoader ¶ added in v0.10.0
type EnvironmentValueLoader struct {
// contains filtered or unexported fields
}
EnvironmentValueLoader implements Loader using Viper
func NewEnvironmentValueLoader ¶ added in v0.10.0
func NewEnvironmentValueLoader(key string, allowList []string) (*EnvironmentValueLoader, error)
NewEnvironmentValueLoader creates a new Viper-based configuration loader to load from environment variables, from a default or specified file (or k8s config map), or some combination
func (*EnvironmentValueLoader) Close ¶ added in v0.10.0
func (l *EnvironmentValueLoader) Close() error
Close closes the environment configuration loader
func (*EnvironmentValueLoader) Get ¶ added in v0.10.0
func (l *EnvironmentValueLoader) Get(key string) (any, error)
Get fetches a particular config value by dot-delimited key from the source
func (*EnvironmentValueLoader) GetConfigKeys ¶ added in v0.10.0
func (l *EnvironmentValueLoader) GetConfigKeys() ([]string, error)
GetConfigKeys returns all the configuration keys found in the environment variables.
func (*EnvironmentValueLoader) Load ¶ added in v0.10.0
func (l *EnvironmentValueLoader) Load(_ Config) error
Load loads the configuration into the provided struct
func (*EnvironmentValueLoader) Name ¶ added in v0.10.0
func (l *EnvironmentValueLoader) Name() string
Name returns the name of the environment configuration loader
type FileLoader ¶ added in v0.10.0
type FileLoader struct {
// contains filtered or unexported fields
}
FileLoader implements Loader using Viper
func NewConfigFileLoader ¶ added in v0.10.0
func NewConfigFileLoader(key, file string) (*FileLoader, error)
NewConfigFileLoader creates a new Viper-based configuration loader to load from a default or specified file.
func (*FileLoader) Close ¶ added in v0.10.0
func (l *FileLoader) Close() error
func (*FileLoader) Get ¶ added in v0.10.0
func (l *FileLoader) Get(key string) (any, error)
Get fetches a particular config value by dot-delimited key from the source
func (*FileLoader) GetConfigKeys ¶ added in v0.10.0
func (l *FileLoader) GetConfigKeys() ([]string, error)
GetConfigKeys returns all the configuration keys found in the config file.
func (*FileLoader) Load ¶ added in v0.10.0
func (l *FileLoader) Load(_ Config) error
Load loads the configuration into the provided struct
func (*FileLoader) Name ¶ added in v0.10.0
func (l *FileLoader) Name() string
type LegacyLoader ¶ added in v0.11.0
type LegacyLoader struct {
// contains filtered or unexported fields
}
LegacyLoader enables loading values from a YAML file and the environment together
func NewLegacyLoader ¶ added in v0.11.0
func NewLegacyLoader(key, file string) (*LegacyLoader, error)
NewLegacyLoader creates a new Viper-based configuration loader to load from a default or specified file.
func (*LegacyLoader) Close ¶ added in v0.11.0
func (l *LegacyLoader) Close() error
func (*LegacyLoader) Get ¶ added in v0.11.0
func (l *LegacyLoader) Get(key string) (any, error)
Get fetches a particular config value by dot-delimited key from the source
func (*LegacyLoader) GetConfigKeys ¶ added in v0.11.0
func (l *LegacyLoader) GetConfigKeys() ([]string, error)
GetConfigKeys returns all the configuration keys found in the config file.
func (*LegacyLoader) Load ¶ added in v0.11.0
func (l *LegacyLoader) Load(cfg Config) error
Load is called to load/refresh the configuration from its source
func (*LegacyLoader) Name ¶ added in v0.11.0
func (l *LegacyLoader) Name() string
type Loader ¶
type Loader interface {
// Get fetches a particular config value by dot-delimited key
Get(key string) (any, error)
// GetConfigKeys returns all the top-level configuration keys that the loader can provide
GetConfigKeys() ([]string, error)
// Load is called to load/refresh the configuration from its source
Load(mostRecentConfig Config) error
// Watch starts watching for configuration changes and invokes an onChange callback
Watch(ctx context.Context, cfg *Config, onChange func(context.Context) error) error
// Close closes the configuration loader
Close() error
// Name returns the name of the configuration loader
Name() string
}
Loader defines the interface for loading and managing configuration
type SDKConfig ¶
type SDKConfig struct {
// Connection to the Core Platform
CorePlatformConnection Connection `mapstructure:"core" json:"core"`
// Connection to an ERS if not in the core platform
EntityResolutionConnection Connection `mapstructure:"entityresolution" json:"entityresolution"`
// ClientID is the client ID used for client credentials grant.
// It is required together with ClientSecret.
ClientID string `mapstructure:"client_id" json:"client_id" validate:"required_with=ClientSecret"`
// ClientSecret is the client secret used for client credentials grant.
// It is required together with ClientID.
ClientSecret string `mapstructure:"client_secret" json:"client_secret" validate:"required_with=ClientID"`
}
SDKConfig represents the configuration for the SDK.
type SecurityConfig ¶ added in v0.11.4
type SecurityConfig struct {
Unsafe UnsafeSecurityConfig `mapstructure:"unsafe" json:"unsafe"`
}
SecurityConfig collects platform-wide security toggles and overrides.
func (*SecurityConfig) ClockSkew ¶ added in v0.11.4
func (s *SecurityConfig) ClockSkew() time.Duration
ClockSkew returns the configured clock skew, defaulting to DefaultUnsafeClockSkew when unset.
type ServiceConfig ¶
Config structure holding a single service.
func (ServiceConfig) LogValue ¶ added in v0.8.2
func (cfg ServiceConfig) LogValue() slog.Value
func (ServiceConfig) String ¶ added in v0.8.2
func (cfg ServiceConfig) String() string
type UnsafeSecurityConfig ¶ added in v0.11.4
type UnsafeSecurityConfig struct {
// ClockSkew increases the tolerated clock skew for token validation. Defaults to 1 minute.
ClockSkew time.Duration `mapstructure:"clock_skew" json:"clock_skew"`
}
UnsafeSecurityConfig exposes overrides that may weaken standard security guarantees.