From 411f413484c3a12b47ddaef66f3c05ef17a26839 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sun, 23 Oct 2016 16:22:49 +0800 Subject: [PATCH] add max retry flag. Signed-off-by: Bo-Yi Wu --- config/config.go | 8 ++++++-- config/config.yml | 2 ++ config/config_test.go | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 58c6e97..fcb4933 100644 --- a/config/config.go +++ b/config/config.go @@ -42,8 +42,9 @@ type SectionAPI struct { // SectionAndroid is sub section of config. type SectionAndroid struct { - Enabled bool `yaml:"enabled"` - APIKey string `yaml:"apikey"` + Enabled bool `yaml:"enabled"` + APIKey string `yaml:"apikey"` + MaxRetry int `yaml:"max_retry"` } // SectionIos is sub section of config. @@ -52,6 +53,7 @@ type SectionIos struct { KeyPath string `yaml:"key_path"` Password string `yaml:"password"` Production bool `yaml:"production"` + MaxRetry int `yaml:"max_retry"` } // SectionLog is sub section of config. @@ -131,12 +133,14 @@ func BuildDefaultPushConf() ConfYaml { // Android conf.Android.Enabled = false conf.Android.APIKey = "" + conf.Android.MaxRetry = 1 // iOS conf.Ios.Enabled = false conf.Ios.KeyPath = "key.pem" conf.Ios.Password = "" conf.Ios.Production = false + conf.Ios.MaxRetry = 1 // log conf.Log.Format = "string" diff --git a/config/config.yml b/config/config.yml index 41d17ba..2d56432 100644 --- a/config/config.yml +++ b/config/config.yml @@ -23,12 +23,14 @@ api: android: enabled: true apikey: "YOUR_API_KEY" + max_retry: 1 ios: enabled: false key_path: "key.pem" password: "" production: false + max_retry: 1 log: format: "string" # string or json diff --git a/config/config_test.go b/config/config_test.go index 0014731..6a1c063 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -78,12 +78,14 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() { // Android assert.Equal(suite.T(), false, suite.ConfGorushDefault.Android.Enabled) assert.Equal(suite.T(), "", suite.ConfGorushDefault.Android.APIKey) + assert.Equal(suite.T(), 1, suite.ConfGorushDefault.Android.MaxRetry) // iOS assert.Equal(suite.T(), false, suite.ConfGorushDefault.Ios.Enabled) assert.Equal(suite.T(), "key.pem", suite.ConfGorushDefault.Ios.KeyPath) assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.Password) assert.Equal(suite.T(), false, suite.ConfGorushDefault.Ios.Production) + assert.Equal(suite.T(), 1, suite.ConfGorushDefault.Ios.MaxRetry) // log assert.Equal(suite.T(), "string", suite.ConfGorushDefault.Log.Format) @@ -131,12 +133,14 @@ func (suite *ConfigTestSuite) TestValidateConf() { // Android assert.Equal(suite.T(), true, suite.ConfGorush.Android.Enabled) assert.Equal(suite.T(), "YOUR_API_KEY", suite.ConfGorush.Android.APIKey) + assert.Equal(suite.T(), 1, suite.ConfGorush.Android.MaxRetry) // iOS assert.Equal(suite.T(), false, suite.ConfGorush.Ios.Enabled) assert.Equal(suite.T(), "key.pem", suite.ConfGorush.Ios.KeyPath) assert.Equal(suite.T(), "", suite.ConfGorush.Ios.Password) assert.Equal(suite.T(), false, suite.ConfGorush.Ios.Production) + assert.Equal(suite.T(), 1, suite.ConfGorush.Ios.MaxRetry) // log assert.Equal(suite.T(), "string", suite.ConfGorush.Log.Format)