-
Notifications
You must be signed in to change notification settings - Fork 62
/
config.go
65 lines (51 loc) · 2.61 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-License-Identifier: AGPL-3.0-only
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
package config
import (
"fmt"
"time"
)
const AppTypeCanal = "canal"
const AppTypeHTTP = "http"
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"`
MySQLHost string `yaml:"mysql_host" env:"MYSQL_HOST" env-default:"127.0.0.1"`
MySQLPort string `yaml:"mysql_port" env:"MYSQL_PORT" env-default:"3306"`
MySQLUserName string `yaml:"mysql_user" env:"MYSQL_USER" env-default:"user"`
MySQLPassword string `yaml:"mysql_pass" env:"MYSQL_PASS" env-default:"password"`
MySQLDatabase string `yaml:"mysql_db" env:"MYSQL_DB" env-default:"bangumi"`
MySQLMaxConn int `yaml:"mysql_max_connection" env:"MYSQL_MAX_CONNECTION" env-default:"4"`
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"`
KafkaBroker string `yaml:"kafka_broker" env:"KAFKA_BROKER"`
KafkaCanalTopics []string `yaml:"kafka_canal_topics"`
MeiliSearchURL string `yaml:"meilisearch_url" env:"MEILISEARCH_URL"`
MeiliSearchKey string `yaml:"meilisearch_key" env:"MEILISEARCH_KEY"`
TurnstileSecretKey string `env:"TURNSTILE_SECRET_KEY" env-default:"1x0000000000000000000000000000000AA"`
TurnstileSiteKey string `env:"TURNSTILE_SITE_KEY" env-default:"1x00000000000000000000AA"`
SearchBatchSize int `env:"SEARCH_BATCH_SIZE" yaml:"search_batch_size" env-default:"100"`
SearchBatchInterval time.Duration `env:"SEARCH_BATCH_INTERVAL" yaml:"search_batch_interval" env-default:"10m"`
SlowSQLDuration time.Duration `yaml:"slow_sql_duration" env:"SLOW_SQL_DURATION"`
NsfwWord string `yaml:"nsfw_word"`
DisableWords string `yaml:"disable_words"`
BannedDomain string `yaml:"banned_domain"`
AppType string
}
func (c AppConfig) ListenAddr() string {
return fmt.Sprintf("%s:%d", c.HTTPHost, c.HTTPPort)
}