-
Notifications
You must be signed in to change notification settings - Fork 7
/
conf.go
38 lines (33 loc) · 1019 Bytes
/
conf.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
package conf
import (
"fmt"
"gopkg.in/yaml.v3"
"tiktok-server/configs"
"tiktok-server/internal/model"
)
const (
ApiServiceName = "api_service"
CommentServiceName = "comment_service"
FavoriteServiceName = "favorite_service"
FeedServiceName = "feed_service"
MessageServiceName = "message_service"
PublishServiceName = "publish_service"
RelationServiceName = "relation_service"
UserServiceName = "user_service"
EtcdAddress = "127.0.0.1:2379"
CPURateLimit float64 = 80.0
WebResourceFolder = "./web/"
)
var Config *model.Config
// Init 加载程序运行所需的配置文件,默认为 configs/config.yml
// TODO init outside config file
func Init() {
data, err := configs.Files.ReadFile("config.yml")
if err != nil {
panic(fmt.Errorf(`read default "config.yml":%w`, err))
}
err = yaml.Unmarshal(data, &Config)
if err != nil {
panic(fmt.Errorf(`parse "config.yml":%w`, err))
}
}