123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- package conf
- import (
- "flag"
- "go-common/library/net/rpc/warden"
- "go-common/library/cache/memcache"
- "go-common/library/cache/redis"
- "go-common/library/conf"
- ecode "go-common/library/ecode/tip"
- "go-common/library/log"
- "go-common/library/log/infoc"
- bm "go-common/library/net/http/blademaster"
- "go-common/library/net/http/blademaster/middleware/antispam"
- "go-common/library/net/http/blademaster/middleware/auth"
- "go-common/library/net/http/blademaster/middleware/supervisor"
- "go-common/library/net/http/blademaster/middleware/verify"
- "go-common/library/net/rpc"
- "go-common/library/net/trace"
- "go-common/library/queue/databus"
- "go-common/library/time"
- "github.com/BurntSushi/toml"
- )
- var (
- confPath string
-
- Conf *Config
- )
- type Config struct {
-
-
- Log *log.Config
- App *bm.App
-
- Fav *Fav
- Platform *Platform
-
- BM *bm.ServerConfig
-
- Redis *Redis
-
- Memcache *Memcache
-
- JobDatabus *databus.Config
-
- Verify *verify.Config
-
- Auth *auth.Config
-
- RPCClient2 *RPC
-
- Tracer *trace.Config
-
- HTTPClient *bm.ClientConfig
-
- Ecode *ecode.Config
-
- Antispam *antispam.Config
-
- Supervisor *supervisor.Config
-
- Infoc2 *infoc.Config
- }
- type RPC struct {
- Archive *rpc.ClientConfig
- Favorite *rpc.ClientConfig
- FavClient *warden.ClientConfig
- }
- type Fav struct {
-
- MaxFolders int
- MaxPagesize int
- MaxNameLen int
- MaxDescLen int
-
- MaxOperationNum int
-
- DefaultFolderLimit int
- NormalFolderLimit int
-
- Expire time.Duration
- }
- type Platform struct {
- MaxFolders int
- MaxNameLen int
- MaxDescLen int
- }
- type Redis struct {
- *redis.Config
- Expire time.Duration
- CoverExpire time.Duration
- }
- type Memcache struct {
- *memcache.Config
- Expire time.Duration
- }
- func init() {
- flag.StringVar(&confPath, "conf", "", "config path")
- }
- func Init() (err error) {
- if confPath == "" {
- return configCenter()
- }
- _, err = toml.DecodeFile(confPath, &Conf)
- return
- }
- func configCenter() (err error) {
- var (
- ok bool
- value string
- client *conf.Client
- )
- if client, err = conf.New(); err != nil {
- return
- }
- if value, ok = client.Toml2(); !ok {
- panic(err)
- }
- _, err = toml.Decode(value, &Conf)
- return
- }
|