Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
SourceISEmpty error = errors.New("field source (path to file or conn str to db) is empty")
)
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶
type AppConfig struct {
ServerCfg ServerConfig `json:"server"`
DataSource DataSourceConfig `json:"data_source"`
Logging LoggingConfig `json:"logging"`
}
func ReadAppConfig ¶ added in v0.9.2
type AppenderConfig ¶ added in v0.1.3
type AppenderConfig struct {
Type AppenderType `json:"type"`
Enabled bool `json:"enabled"`
Level string `json:"level"`
Destination *DestinationConfig `json:"destination"`
}
type AppenderType ¶ added in v0.1.3
type AppenderType string
const ( RollingFile AppenderType = "rolling_file" Console = "console" )
type CredentialsConfig ¶ added in v0.9.2
type DataSourceConfig ¶ added in v0.9.2
type DataSourceConfig struct {
Type DataSourceType `json:"type"`
Source string `json:"source"`
Credentials *CredentialsConfig `json:"credentials"`
Options map[DataSourceConnOption]string `json:"options"`
}
DataSourceConfig represent source where we can get
- We attempt to provide config that easily could be used with any datasource:
- - json file (simplest RO mode)
- - mongodb (but here we have very simple question how to pass parameters)
- Source contains:
- 1) if Type is FILE - full path to Json File
- 2) if Type is REDIS - redis server address i.e. localhost:6739
- Options are connection options, see - https://www.mongodb.com/docs/drivers/go/current/fundamentals/connection/#std-label-golang-connection-guide
- Here we should have Validator too
- Credentials contains Username && Password could be null id authorization is not required: *
func (*DataSourceConfig) Validate ¶ added in v0.9.2
func (cfg *DataSourceConfig) Validate() error
type DataSourceConnOption ¶ added in v0.9.2
type DataSourceConnOption string
const ( // DbNumber is a REDIS connection options, here we expect to receive int in a string DbNumber DataSourceConnOption = "db_number" // UseTls is a REDIS option to set up tls.Config and use TLS connection, here we expect to receive bool value in a string UseTls DataSourceConnOption = "use_tls" // InsecureTls is a REDIS option to set up TLSConfig: &tls.Config{InsecureSkipVerify: true}, here we expect to receive bool value in a string InsecureTls DataSourceConnOption = "allow_insecure_tls" // Namespace is a prefix before any key Namespace DataSourceConnOption = "namespace" )
const ( OperationTimeout DataSourceConnOption = "timeoutMS" ConnectionTimeout DataSourceConnOption = "connectTimeoutMS" ConnectionsPool DataSourceConnOption = "maxPoolSize" ReplicaSet DataSourceConnOption = "replicaSet" MaxIdleTime DataSourceConnOption = "maxIdleTimeMS" SocketTimeout DataSourceConnOption = "socketTimeoutMS" ServerSelectionTimeout DataSourceConnOption = "serverSelectionTimeoutMS" HeartbeatFrequency DataSourceConnOption = "heartbeatFrequencyMS" Tls DataSourceConnOption = "tls" WriteConcern DataSourceConnOption = "w" DirectConnection DataSourceConnOption = "directConnection" )
type DataSourceType ¶ added in v0.9.2
type DataSourceType string
const ( FILE DataSourceType = "file" // MONGODB TODO (UMV): Mongo won't be using for sometime, maybe it will be removed completely MONGODB DataSourceType = "mongodb" // REDIS : redis server should be running with dump every write on a disk (AOF) REDIS DataSourceType = "redis" )
type DestinationConfig ¶ added in v0.1.3
type LoggingConfig ¶ added in v0.1.3
type LoggingConfig struct {
Level string `json:"level"`
Appenders []AppenderConfig `json:"appenders"`
ConsoleOutHTTP bool `json:"http_console_out"`
LogHTTP bool `json:"http_log"`
}
func (*LoggingConfig) Validate ¶ added in v0.9.2
func (cfg *LoggingConfig) Validate() error
type RedisConfig ¶ added in v0.9.2
type RedisConfig struct {
Address string `json:"address" example:"localhost:6379"`
Password string `json:"password"`
DbNumber int `json:"db_number"`
Namespace string `json:"namespace"`
// MaxRetries is a number of attempts to
MaxRetries int `json:"max_retries"`
// MinRetryBackoff is a backoff in milliseconds
MinRetryBackoff int `json:"min_retry_backoff"`
MaxRetryBackoff int `json:"max_retry_backoff"`
// go-redis dial timeout option is time, here we simplify config we assume here Seconds as a time value, 0 means no timeout
DialTimeout uint `json:"dial_timeout"`
// go-redis read timeout option is time, here we simplify config we assume here Seconds as a time value, 0 means no timeout
ReadTimeout uint `json:"read_timeout"`
// go-redis write timeout option is time, here we simplify config we assume here Seconds as a time value, 0 means no timeout
WriteTimeout uint `json:"write_timeout"`
PoolSize uint `json:"pool_size"`
// go-redis pool timeout option is time, here we simplify config we assume here Seconds as a time value, 0 means 1 sec to pool timeout
PoolTimeout uint `json:"pool_timeout"`
MinIdleConn int `json:"min_idle_conn"`
MaxIdleConn int `json:"max_idle_conn"`
// default is 30 min (go-redis), 0 disable max timeout (pass -1 to go-redis)
ConnIdleTimeout uint `json:"conn_idle_timeout"`
// by default go-redis do not close idle connections
ConnMaxLifetimeTimeout int `json:"conn_max_lifetime_timeout"`
ReadOnlySlaveEnabled bool `json:"read_only_slave_enabled"`
TlsCfg *tls.Config `json:"tls_cfg"`
}
RedisConfig is a simplified redis.Options config
type SecurityConfig ¶
type ServerConfig ¶
type ServerConfig struct {
Schema Schema `json:"schema" example:"http or https"`
Address string `json:"address" example:"127.0.0.1 or mydomain.com"`
Port int `json:"port" example:"8080"`
Security *SecurityConfig `json:"security"`
SecretFile string `json:"secret_file" example:"./keyfile"`
}
func (*ServerConfig) Validate ¶ added in v0.9.2
func (cfg *ServerConfig) Validate() error
type ValidatingConfig ¶ added in v0.9.2
type ValidatingConfig interface {
Validate() error
}
ValidatingConfig is interface that contains config struct and Validate method to check whether config can be used further or not
Click to show internal directories.
Click to hide internal directories.