config

package
v0.0.0-rc7 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalMode       = Mode("local")
	DevelopmentMode = Mode("development")
	ProductionMode  = Mode("production")
	TestMode        = Mode("test")
)
View Source
const (
	MemoryCacheType       = CacheType("memory")
	RedisCacheType        = CacheType("redis")
	RedisClusterCacheType = CacheType("redis_cluster")
)
View Source
const (
	MemoryPubSubType = PubSubType("memory")
	RedisPubSubType  = PubSubType("redis")
)
View Source
const (
	LogLevelDebug = LogLevel("debug")
	LogLevelInfo  = LogLevel("info")
	LogLevelWarn  = LogLevel("warning")
	LogLevelError = LogLevel("error")
)
View Source
const (
	LogEncodingText = LogEncoding("text")
	LogEncodingJson = LogEncoding("json")
)
View Source
const (
	MinioS3Type = S3Type("minio")
)
View Source
const (
	PostgresDatabaseType = DatabaseType("postgres")
)

Variables

This section is empty.

Functions

func GetConfigName

func GetConfigName() string

Types

type CacheConfig

type CacheConfig struct {
	TTL   int               `default:"120" validate:"required,min=0"`
	Type  CacheType         `default:"memory" validate:"required,oneof=memory redis"`
	Redis *RedisCacheConfig `validate:"required_if=Type redis"`
}

type CacheType

type CacheType string

type Config

type Config struct {
	Server           ServerConfig
	Database         DatabaseConfig
	Cache            CacheConfig
	S3               S3Config
	PubSub           PubSubConfig
	SMTP             SmtpConfig
	Websocket        WebsocketConfig
	Locale           LocaleConfig
	Template         TemplateConfig
	Migrations       MigrationConfig
	Logger           LoggerConfig
	OAuthClients     map[string]OauthClientConfig
	GeocodingClients map[string]GeocodingClientConfig
	Security         SecurityConfig
}

type ConsoleLoggerConfig

type ConsoleLoggerConfig struct {
	Enable   bool   `default:"true"`
	Encoding string `default:"text" validate:"required_with=Enable"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Type     DatabaseType            `default:"postgres" validate:"required,oneof=postgres"`
	Postgres *PostgresDatabaseConfig `validate:"required_if=Type postgres"`
}

type DatabaseType

type DatabaseType string

type FileLoggerConfig

type FileLoggerConfig struct {
	Enable  bool   `default:"false"`
	DirPath string `default:"logs" validate:"required_with=Enable"`
	MaxSize int    `default:"100" validate:"required_with=Enable,min=0"`
	MaxAge  int    `default:"30" validate:"required_with=Enable,min=0"`
}

type GeocodingClientConfig

type GeocodingClientConfig struct {
	APIKey string `validate:"required"`
}

type JWTConfig

type JWTConfig struct {
	Secret          string `validate:"required"`
	AccessTokenTTL  int    `default:"3600" validate:"required,min=0"`
	RefreshTokenTTL int    `default:"86400" validate:"required,min=0"`
}

type LocaleConfig

type LocaleConfig struct {
	Path     string `default:"locales" validate:"required"`
	Language string `default:"ru" validate:"required"`
}

type LogEncoding

type LogEncoding string

type LogLevel

type LogLevel string

type LoggerConfig

type LoggerConfig struct {
	Level   string `default:"info" validate:"required"`
	Console ConsoleLoggerConfig
	File    FileLoggerConfig
}

type MigrationConfig

type MigrationConfig struct {
	Path string `default:"migrations" validate:"required"`
}

type MinioS3Config

type MinioS3Config struct {
	Address   string `validate:"required"`
	AccessKey string `validate:"required"`
	SecretKey string `validate:"required"`
	Bucket    string `validate:"required"`
}

type Mode

type Mode string

type OTPConfig

type OTPConfig struct {
	Length int `default:"6" validate:"required,min=4"`
	TTL    int `default:"600" validate:"required,min=0"`
}

type OauthClientConfig

type OauthClientConfig struct {
	ClientID     string `validate:"required"`
	ClientSecret string `validate:"required"`
}

type PostgresDatabaseConfig

type PostgresDatabaseConfig struct {
	Address  string `validate:"required"`
	Username string `validate:"required"`
	Password string `validate:"required"`
	DBName   string `validate:"required"`
}

type PubSubConfig

type PubSubConfig struct {
	Type  PubSubType         `default:"memory" validate:"required,oneof=memory redis"`
	Redis *RedisPubSubConfig `validate:"required_if=Type redis"`
}

type PubSubType

type PubSubType string

type RedisCacheConfig

type RedisCacheConfig struct {
	Address  string `validate:"required"`
	Username string `default:"default" validate:"required"`
	Password string `validate:"required"`
	DBIndex  int    `default:"0" validate:"min=0"`
}

type RedisPubSubConfig

type RedisPubSubConfig struct {
	Address  string `validate:"required"`
	Username string
	Password string
	DBIndex  int `default:"0" validate:"min=0"`
}

type S3Config

type S3Config struct {
	Type  S3Type         `default:"minio" validate:"required,oneof=minio"`
	Minio *MinioS3Config `validate:"required_if=Type minio"`
}

type S3Type

type S3Type string

type SecurityConfig

type SecurityConfig struct {
	JWT JWTConfig
	OTP OTPConfig
}

type ServerConfig

type ServerConfig struct {
	Name           string `default:"server" validate:"required"`
	Port           int    `default:"8000" validate:"min=-1,max=65535"`
	ExternalOrigin string `default:"http://localhost:8080" validate:"omitempty,http_url"`
	Mode           Mode   `default:"local" validate:"required,oneof=local development production test"`
	Version        string `default:"0.0.0"`
	MaxRequestSize int    `default:"524288000" validate:"min=0"`
	RPS            int    `default:"100" validate:"required,min=1"`
}

type SmtpConfig

type SmtpConfig struct {
	Host     string `validate:"required"`
	Port     int    `validate:"required"`
	Username string
	Password string
	SSL      bool
	From     string `validate:"required"`
}

type TemplateConfig

type TemplateConfig struct {
	Path string `default:"templates" validate:"required"`
}

type WebsocketConfig

type WebsocketConfig struct {
	PoolSize int `default:"1024" validate:"min=0"`
}

Jump to

Keyboard shortcuts

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