chore: support single queue and multiple worker (#589)

This commit is contained in:
Bo-Yi Wu
2021-07-16 12:10:34 +08:00
committed by GitHub
parent 0658f18430
commit ab8b1991ab
34 changed files with 1020 additions and 881 deletions

View File

@@ -243,7 +243,7 @@ type SectionGRPC struct {
}
// LoadConf load config from file and read in environment variables that match
func LoadConf(confPath string) (ConfYaml, error) {
func LoadConf(confPath ...string) (ConfYaml, error) {
var conf ConfYaml
viper.SetConfigType("yaml")
@@ -251,8 +251,8 @@ func LoadConf(confPath string) (ConfYaml, error) {
viper.SetEnvPrefix("gorush") // will be uppercased automatically
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
if confPath != "" {
content, err := ioutil.ReadFile(confPath)
if len(confPath) > 0 && confPath[0] != "" {
content, err := ioutil.ReadFile(confPath[0])
if err != nil {
return conf, err
}

View File

@@ -25,7 +25,7 @@ type ConfigTestSuite struct {
func (suite *ConfigTestSuite) SetupTest() {
var err error
suite.ConfGorushDefault, err = LoadConf("")
suite.ConfGorushDefault, err = LoadConf()
if err != nil {
panic("failed to load default config.yml")
}
@@ -215,6 +215,6 @@ func TestLoadConfigFromEnv(t *testing.T) {
func TestLoadWrongDefaultYAMLConfig(t *testing.T) {
defaultConf = []byte(`a`)
_, err := LoadConf("")
_, err := LoadConf()
assert.Error(t, err)
}