config

package
v0.0.0-...-ccf851b Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConfigNotLoaded is returned when configuration access is attempted
	// before the configuration has been fully loaded.
	ErrConfigNotLoaded = errors.New("config not loaded")
)

Functions

This section is empty.

Types

type ExtractSectionsResult

type ExtractSectionsResult struct {
	fx.Out

	ServerConfig        ServerConfig
	ServerHTTPConfig    ServerHTTPConfig
	ServerDBConfig      ServerDBConfig
	ServerRedisConfig   ServerRedisConfig
	ServerLockerConfig  ServerLockerConfig
	ServerStorageConfig ServerStorageConfig
	ServerNATSConfig    ServerNATSConfig
	SnowflakeConfig     SnowflakeConfig
	LoggingConfig       LoggingConfig
	TraceConfig         TraceConfig
	MetricConfig        MetricConfig
	SecureConfig        SecureConfig
	SecureTokenConfig   SecureTokenConfig
}

ExtractSectionsResult is a container of individual configuration sections returned from ExtractSections for dependency injection via fx.Out.

func ExtractSections

func ExtractSections(cfg RootConfig) ExtractSectionsResult

ExtractSections extracts sections from RootConfig. It is used for dependency injection.

type LoggingConfig

type LoggingConfig interface {
	GetZapLogger() LoggingZapLoggerConfig
	GetSlogLogger() LoggingSlogLoggerConfig
}

LoggingConfig selects logging implementations and presets for the service.

type LoggingSlogLoggerConfig

type LoggingSlogLoggerConfig interface {
	GetHandler() string
	GetAddSource() bool
	GetLeveler() slog.Leveler
}

LoggingSlogLoggerConfig controls settings for slog logging.

type LoggingZapLoggerConfig

type LoggingZapLoggerConfig interface {
	GetPreset() string
}

LoggingZapLoggerConfig configures the zap logger preset.

type MetricConfig

type MetricConfig interface {
	GetExporterConfig() MetricExporterConfig
}

MetricConfig describes OpenTelemetry metrics configuration.

type MetricExporterConfig

type MetricExporterConfig interface {
	GetProtocol() string
	GetEndpoint() string
	GetInsecure() bool
}

MetricExporterConfig defines options for the metrics exporter.

type RootConfig

type RootConfig interface {
	// GetValue retrieves a value from the configuration by its path.
	// The path is a valid JSON path, e.g. "$.server.http.addr".
	GetValue(path string, value any) error
	GetServerConfig() ServerConfig
	GetSnowflakeConfig() SnowflakeConfig
	GetLoggingConfig() LoggingConfig
	GetTraceConfig() TraceConfig
	GetMetricConfig() MetricConfig
	GetSecureConfig() SecureConfig
}

RootConfig represents the top-level configuration container loaded from external sources. Implementations must provide access to specific configuration sections used throughout the application.

func LoadYamlConfig

func LoadYamlConfig() (RootConfig, error)

LoadYamlConfig loads RootConfig from file. The path of the file is specified by environment variable GOMMERCE_CONFIG_PATH, If the environment variable is not set, it defaults to "./config/app-deploy.yaml".

type SecureConfig

type SecureConfig interface {
	GetToken() SecureTokenConfig
}

SecureConfig encompasses security and token-related settings.

type SecureTokenConfig

type SecureTokenConfig interface {
	GetStore() string
	GetBucket() string
	GetIssuer() string
	GetAudience() string
	GetSigningMethod() string
	GetAccessTokenTTL() time.Duration
	GetRefreshTokenTTL() time.Duration
	GetPublicKey() []byte
	GetPrivateKey() []byte
}

SecureTokenConfig provides parameters for issuing and verifying tokens.

type ServerConfig

type ServerConfig interface {
	GetDebug() bool
	GetName() string
	GetVersion() string
	GetInstanceId() string
	GetHTTPConfig() ServerHTTPConfig
	GetDBConfig() ServerDBConfig
	GetRedisConfig() ServerRedisConfig
	GetLockerConfig() ServerLockerConfig
	GetStorageConfig() ServerStorageConfig
	GetNATSConfig() ServerNATSConfig
}

ServerConfig contains runtime configuration for the HTTP/gRPC server and related components.

type ServerDBConfig

type ServerDBConfig interface {
	GetDriver() string
	GetSource() string
}

ServerDBConfig captures database connection settings.

type ServerHTTPConfig

type ServerHTTPConfig interface {
	GetAddr() string
	GetCors() cors.Options
}

ServerHTTPConfig defines the configuration for the embedded HTTP server.

type ServerLockerConfig

type ServerLockerConfig interface {
	GetKeyPrefix() string
	GetKeyValidity() time.Duration
	GetExtendInterval() time.Duration
	GetTryNextAfter() time.Duration
	GetKeyMajority() int32
	GetNoLoopTracking() bool
	GetFallbackSETPX() bool
}

ServerLockerConfig defines options for the distributed locking mechanism.

type ServerNATSConfig

type ServerNATSConfig interface {
	GetSeedURL() string
	GetNoEcho() bool
}

ServerNATSConfig holds the NATS connection options.

type ServerRedisConfig

type ServerRedisConfig interface {
	GetInitAddr() string
	GetSelectDB() int
}

ServerRedisConfig describes the Redis connection configuration.

type ServerStorageConfig

type ServerStorageConfig interface {
	GetRegion() string
	GetEndpoint() string
	GetAccessKey() string
	GetSecretKey() string
}

ServerStorageConfig specifies settings for the object storage backend.

type SnowflakeConfig

type SnowflakeConfig interface {
	GetIDEpoch() int64
	GetClusterID() int64
	GetWorkerID() int64
	GetWorkerSeqKey() string
	GetClusterIDBits() int32
	GetWorkerIDBits() int32
	GetSequenceBits() int32
}

SnowflakeConfig exposes configuration for the Snowflake ID generator.

type TraceConfig

type TraceConfig interface {
	GetExporterConfig() TraceExporterConfig
}

TraceConfig describes OpenTelemetry tracing options.

type TraceExporterConfig

type TraceExporterConfig interface {
	GetProtocol() string
	GetEndpoint() string
	GetInsecure() bool
}

TraceExporterConfig defines options for the trace exporter.

Jump to

Keyboard shortcuts

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