config

package
v0.33.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: AGPL-3.0, AGPL-3.0-only Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AppTypeCanal = "canal"
View Source
const AppTypeHTTP = "http"
View Source
const RedisKeyPrefix = "chii:" + Version + ":"

RedisKeyPrefix is redis key prefix for all app keys Put version in cache key to avoid model changes.

View Source
const Version = "development"

Variables

This section is empty.

Functions

func AppConfigReader added in v0.30.3

func AppConfigReader(appType string) func() (AppConfig, error)

Types

type AppConfig

type AppConfig struct {
	Debug struct {
		Gorm bool `yaml:"gorm"`
	} `yaml:"debug"`

	RedisURL string `yaml:"redis_url" env:"REDIS_URI" env-default:"redis://127.0.0.1:6379/0"`

	Mysql struct {
		Host        string        `yaml:"host" env:"MYSQL_HOST" env-default:"127.0.0.1"`
		Port        string        `yaml:"port" env:"MYSQL_PORT" env-default:"3306"`
		UserName    string        `yaml:"user" env:"MYSQL_USER" env-default:"user"`
		Password    string        `yaml:"password" env:"MYSQL_PASS" env-default:"password"`
		Database    string        `yaml:"db" env:"MYSQL_DB" env-default:"bangumi"`
		MaxConn     int           `yaml:"max_connection" env:"MYSQL_MAX_CONNECTION" env-default:"4"`
		MaxIdleTime time.Duration `yaml:"conn_max_idle_time" env-default:"4h"`
		MaxLifeTime time.Duration `yaml:"conn_max_life_time" env-default:"6h"`

		SlowSQLDuration time.Duration `yaml:"slow_sql_duration" env:"SLOW_SQL_DURATION"`
	} `yaml:"mysql"`

	WebDomain string `yaml:"web_domain" env:"WEB_DOMAIN"` // new frontend web page domain
	HTTPHost  string `yaml:"http_host" env:"HTTP_HOST" env-default:"127.0.0.1"`
	HTTPPort  int    `yaml:"http_port" env:"HTTP_PORT" env-default:"3000"`

	Canal struct {
		Broker string `yaml:"broker"`

		KafkaBroker string   `yaml:"kafka_broker" env:"KAFKA_BROKER"`
		Topics      []string `yaml:"topics"`
	} `yaml:"canal"`

	Search struct {
		MeiliSearch struct {
			URL string `yaml:"url" env:"MEILISEARCH_URL"`
			Key string `yaml:"key" env:"MEILISEARCH_KEY"`
		} `yaml:"meilisearch"`

		SearchBatchSize     int           `env:"SEARCH_BATCH_SIZE" yaml:"batch_size" env-default:"100"`
		SearchBatchInterval time.Duration `env:"SEARCH_BATCH_INTERVAL" yaml:"batch_interval" env-default:"10m"`
	} `yaml:"search"`

	NsfwWord     string `yaml:"nsfw_word"`
	DisableWords string `yaml:"disable_words"`
	BannedDomain string `yaml:"banned_domain"`

	// "http://localhost:2379"
	EtcdAddr      string `yaml:"etcd_addr" env:"ETCD_ADDR"`
	EtcdNamespace string `yaml:"etcd_namespace" env:"ETCD_NAMESPACE"  env-default:"/chii/services"`

	S3EntryPoint        string `yaml:"s3_entry_point" env:"S3_ENTRY_POINT"`
	S3AccessKey         string `yaml:"s3_access_key" env:"S3_ACCESS_KEY"`
	S3SecretKey         string `yaml:"s3_secret_key" env:"S3_SECRET_KEY"`
	S3ImageResizeBucket string `yaml:"s3_image_resize_bucket" env:"S3_IMAGE_RESIZE_BUCKET" env-default:"img-resize"`

	AppType string
}

func NewAppConfig

func NewAppConfig() (AppConfig, error)

func (AppConfig) ListenAddr added in v0.30.3

func (c AppConfig) ListenAddr() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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