Documentation
¶
Overview ¶
Package config provides configuration structures and utilities for fxconfig. It defines the configuration schema and handles loading from multiple sources with a well-defined precedence hierarchy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Logging LoggingConfig `mapstructure:"logging" yaml:"logging,omitempty"`
MSP MSPConfig `mapstructure:"msp" yaml:"msp,omitempty"`
TLS TLSConfig `mapstructure:"tls" yaml:"tls,omitempty"`
Orderer OrdererConfig `mapstructure:"orderer" yaml:"orderer,omitempty"`
Queries QueriesConfig `mapstructure:"queries" yaml:"queries,omitempty"`
Notifications NotificationsConfig `mapstructure:"notifications" yaml:"notifications,omitempty"`
}
Config represents the complete fxconfig configuration. It includes settings for logging, MSP identity, TLS, and service endpoints.
func Load ¶
Load loads configuration from multiple sources with a defined precedence hierarchy. Configuration is merged in order: user config, project config, environment variables, explicit config file (via WithConfigFile), and finally CLI flag overrides (via WithOverride). Returns a fully resolved Config with TLS settings inherited and merged across services.
func (*Config) ResolveTLS ¶
func (c *Config) ResolveTLS()
ResolveTLS applies TLS configuration inheritance across all services. Each service inherits from the parent TLS config unless it provides overrides. After merging, all TLS configs are normalized to have explicit enabled flags.
type EndpointServiceConfig ¶
type EndpointServiceConfig struct {
Address string `mapstructure:"address" yaml:"address,omitempty" desc:"Service address (host:port)"`
ConnectionTimeout time.Duration `mapstructure:"connectionTimeout" yaml:"connectionTimeout,omitempty" desc:"Connection timeout duration" default:"30s"`
TLS *TLSConfig `mapstructure:"tls" yaml:"tls,omitempty" desc:"(Optional) Overrides parent TLS section"`
}
EndpointServiceConfig defines connection settings for a Fabric-X service. Each service (orderer, queries, notifications) can have its own configuration.
func (*EndpointServiceConfig) Validate ¶
func (c *EndpointServiceConfig) Validate(vctx validation.Context) error
Validate validates service endpoint configuration. Checks address, timeout, and TLS settings for a given service.
type LoggingConfig ¶
type LoggingConfig struct {
Level string `mapstructure:"level" yaml:"level,omitempty" desc:"Logging level" default:"error"`
Format string `mapstructure:"format" yaml:"format,omitempty" desc:"logging format"`
}
LoggingConfig controls logging behavior.
type MSPConfig ¶
type MSPConfig struct {
LocalMspID string `mapstructure:"localMspID" yaml:"localMspID,omitempty" desc:"MSP ID of the organization"`
ConfigPath string `mapstructure:"configPath" yaml:"configPath,omitempty" desc:"Path to MSP configuration directory"`
}
MSPConfig contains MSP (Membership Service Provider) identity configuration. It specifies which organization identity to use for signing transactions.
type NotificationsConfig ¶
type NotificationsConfig struct {
EndpointServiceConfig `mapstructure:",squash" yaml:",inline"`
WaitingTimeout time.Duration `mapstructure:"waitingTimeout" yaml:"waitingTimeout,omitempty" desc:"Time to wait for notification processing" default:"30s"`
}
NotificationsConfig contains configuration for the notifications service endpoint. Includes a waiting timeout for notification processing operations.
type Option ¶
Option is a functional option for configuring the configuration loader.
func WithConfigFile ¶
WithConfigFile specifies an explicit configuration file path to load. This takes precedence over project and user config files.
func WithOverride ¶
WithOverride sets a configuration value that overrides all other sources. This is typically used for command-line flag values.
type OrdererConfig ¶
type OrdererConfig struct {
EndpointServiceConfig `mapstructure:",squash" yaml:",inline"`
Channel string `mapstructure:"channel" yaml:"channel,omitempty" desc:"Orderer channel name" default:"mychannel"`
}
OrdererConfig contains configuration for the ordering service endpoint.
func (*OrdererConfig) Validate ¶
func (c *OrdererConfig) Validate(vctx validation.Context) error
Validate validates Orderer configuration. Check channel name and endpoint service configuration.
type QueriesConfig ¶
type QueriesConfig struct {
EndpointServiceConfig `mapstructure:",squash" yaml:",inline"`
}
QueriesConfig contains configuration for the query service endpoint.
type TLSConfig ¶
type TLSConfig struct {
Enabled *bool `mapstructure:"enabled" yaml:"enabled,omitempty" desc:"Enable/disable TLS" default:"false"`
ClientKeyPath string `mapstructure:"clientKey" yaml:"clientKey,omitempty" desc:"Path to TLS client private key"`
ClientCertPath string `mapstructure:"clientCert" yaml:"clientCert,omitempty" desc:"Path to TLS client certificate"`
RootCertPaths []string `mapstructure:"rootCerts" yaml:"rootCerts,omitempty" desc:"Paths to TLS root certificates"`
ServerNameOverride string `mapstructure:"serverNameOverride" yaml:"serverNameOverride,omitempty" desc:"Override TLS server name"`
}
TLSConfig specifies TLS settings for secure communication. Supports three modes: no TLS, server TLS (rootCerts only), and mutual TLS (all fields).
func (*TLSConfig) InheritFrom ¶
InheritFrom returns a new TLSConfig that merges c with parent, preferring c's values where set.
func (*TLSConfig) IsEnabled ¶
IsEnabled returns whether TLS is enabled for this configuration. Returns false if the config is nil or the enabled flag is not set.