feat(config): add grpc config. (#255)
This commit is contained in:
@@ -15,6 +15,7 @@ type ConfYaml struct {
|
||||
Ios SectionIos `yaml:"ios"`
|
||||
Log SectionLog `yaml:"log"`
|
||||
Stat SectionStat `yaml:"stat"`
|
||||
GRPC SectionGRPC `yaml:"grpc"`
|
||||
}
|
||||
|
||||
// SectionCore is sub section of config.
|
||||
@@ -115,6 +116,12 @@ type SectionPID struct {
|
||||
Override bool `yaml:"override"`
|
||||
}
|
||||
|
||||
// SectionGRPC is sub section of config.
|
||||
type SectionGRPC struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Port string `yaml:"port"`
|
||||
}
|
||||
|
||||
// BuildDefaultPushConf is default config setting.
|
||||
func BuildDefaultPushConf() ConfYaml {
|
||||
var conf ConfYaml
|
||||
@@ -165,17 +172,19 @@ func BuildDefaultPushConf() ConfYaml {
|
||||
conf.Log.ErrorLevel = "error"
|
||||
conf.Log.HideToken = true
|
||||
|
||||
// Stat Engine
|
||||
conf.Stat.Engine = "memory"
|
||||
conf.Stat.Redis.Addr = "localhost:6379"
|
||||
conf.Stat.Redis.Password = ""
|
||||
conf.Stat.Redis.DB = 0
|
||||
|
||||
conf.Stat.BoltDB.Path = "bolt.db"
|
||||
conf.Stat.BoltDB.Bucket = "gorush"
|
||||
|
||||
conf.Stat.BuntDB.Path = "bunt.db"
|
||||
conf.Stat.LevelDB.Path = "level.db"
|
||||
|
||||
// gRPC Server
|
||||
conf.GRPC.Enabled = false
|
||||
conf.GRPC.Port = "50051"
|
||||
return conf
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ core:
|
||||
folder: ".cache" # folder for storing TLS certificates
|
||||
host: "" # which domains the Let's Encrypt will attempt
|
||||
|
||||
grpc:
|
||||
enabled: false
|
||||
port: 50051
|
||||
|
||||
api:
|
||||
push_uri: "/api/push"
|
||||
stat_go_uri: "/api/stat/go"
|
||||
|
||||
@@ -111,6 +111,10 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() {
|
||||
|
||||
assert.Equal(suite.T(), "bunt.db", suite.ConfGorushDefault.Stat.BuntDB.Path)
|
||||
assert.Equal(suite.T(), "level.db", suite.ConfGorushDefault.Stat.LevelDB.Path)
|
||||
|
||||
// gRPC
|
||||
assert.Equal(suite.T(), false, suite.ConfGorushDefault.GRPC.Enabled)
|
||||
assert.Equal(suite.T(), "50051", suite.ConfGorushDefault.GRPC.Port)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestValidateConf() {
|
||||
@@ -171,6 +175,10 @@ func (suite *ConfigTestSuite) TestValidateConf() {
|
||||
|
||||
assert.Equal(suite.T(), "bunt.db", suite.ConfGorush.Stat.BuntDB.Path)
|
||||
assert.Equal(suite.T(), "level.db", suite.ConfGorush.Stat.LevelDB.Path)
|
||||
|
||||
// gRPC
|
||||
assert.Equal(suite.T(), false, suite.ConfGorush.GRPC.Enabled)
|
||||
assert.Equal(suite.T(), "50051", suite.ConfGorush.GRPC.Port)
|
||||
}
|
||||
|
||||
func TestConfigTestSuite(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user