From 9cfe693ad92aecb95e29d98186a83d13eaafbe4f Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 2 May 2016 12:16:39 +0800 Subject: [PATCH] switch default private key to public. Signed-off-by: Bo-Yi Wu --- gorush/const.go | 10 +++++----- gorush/status.go | 40 ++++++++++++++++++++-------------------- storage/redis/redis.go | 28 ++++++++++------------------ 3 files changed, 35 insertions(+), 43 deletions(-) diff --git a/gorush/const.go b/gorush/const.go index 9a3c383..b2edc81 100644 --- a/gorush/const.go +++ b/gorush/const.go @@ -21,9 +21,9 @@ const ( // Stat variable for redis const ( - gorushTotalCount = "gorush-total-count" - gorushIosSuccess = "gorush-ios-success-count" - gorushIosError = "gorush-ios-error-count" - gorushAndroidSuccess = "gorush-android-success-count" - gorushAndroidError = "gorush-android-error-count" + TotalCountKey = "gorush-total-count" + IosSuccessKey = "gorush-ios-success-count" + IosErrorKey = "gorush-ios-error-count" + AndroidSuccessKey = "gorush-android-success-count" + AndroidErrorKey = "gorush-android-error-count" ) diff --git a/gorush/status.go b/gorush/status.go index 10fa817..b221e82 100644 --- a/gorush/status.go +++ b/gorush/status.go @@ -108,9 +108,9 @@ func addTotalCount(count int64) { case "memory": atomic.AddInt64(&RushStatus.TotalCount, count) case "redis": - RedisClient.Set(gorushTotalCount, strconv.Itoa(int(count)), 0) + RedisClient.Set(TotalCountKey, strconv.Itoa(int(count)), 0) case "boltdb": - boltdbSet(gorushTotalCount, count) + boltdbSet(TotalCountKey, count) default: atomic.AddInt64(&RushStatus.TotalCount, count) } @@ -121,9 +121,9 @@ func addIosSuccess(count int64) { case "memory": atomic.AddInt64(&RushStatus.Ios.PushSuccess, count) case "redis": - RedisClient.Set(gorushIosSuccess, strconv.Itoa(int(count)), 0) + RedisClient.Set(IosSuccessKey, strconv.Itoa(int(count)), 0) case "boltdb": - boltdbSet(gorushIosSuccess, count) + boltdbSet(IosSuccessKey, count) default: atomic.AddInt64(&RushStatus.Ios.PushSuccess, count) } @@ -134,9 +134,9 @@ func addIosError(count int64) { case "memory": atomic.AddInt64(&RushStatus.Ios.PushError, count) case "redis": - RedisClient.Set(gorushIosError, strconv.Itoa(int(count)), 0) + RedisClient.Set(IosErrorKey, strconv.Itoa(int(count)), 0) case "boltdb": - boltdbSet(gorushIosError, count) + boltdbSet(IosErrorKey, count) default: atomic.AddInt64(&RushStatus.Ios.PushError, count) } @@ -147,9 +147,9 @@ func addAndroidSuccess(count int64) { case "memory": atomic.AddInt64(&RushStatus.Android.PushSuccess, count) case "redis": - RedisClient.Set(gorushAndroidSuccess, strconv.Itoa(int(count)), 0) + RedisClient.Set(AndroidSuccessKey, strconv.Itoa(int(count)), 0) case "boltdb": - boltdbSet(gorushAndroidSuccess, count) + boltdbSet(AndroidSuccessKey, count) default: atomic.AddInt64(&RushStatus.Android.PushSuccess, count) } @@ -160,9 +160,9 @@ func addAndroidError(count int64) { case "memory": atomic.AddInt64(&RushStatus.Android.PushError, count) case "redis": - RedisClient.Set(gorushAndroidError, strconv.Itoa(int(count)), 0) + RedisClient.Set(AndroidErrorKey, strconv.Itoa(int(count)), 0) case "boltdb": - boltdbSet(gorushAndroidError, count) + boltdbSet(AndroidErrorKey, count) default: atomic.AddInt64(&RushStatus.Android.PushError, count) } @@ -174,9 +174,9 @@ func getTotalCount() int64 { case "memory": count = atomic.LoadInt64(&RushStatus.TotalCount) case "redis": - getRedisInt64Result(gorushTotalCount, &count) + getRedisInt64Result(TotalCountKey, &count) case "boltdb": - boltdbGet(gorushTotalCount, &count) + boltdbGet(TotalCountKey, &count) default: count = atomic.LoadInt64(&RushStatus.TotalCount) } @@ -190,9 +190,9 @@ func getIosSuccess() int64 { case "memory": count = atomic.LoadInt64(&RushStatus.Ios.PushSuccess) case "redis": - getRedisInt64Result(gorushIosSuccess, &count) + getRedisInt64Result(IosSuccessKey, &count) case "boltdb": - boltdbGet(gorushIosSuccess, &count) + boltdbGet(IosSuccessKey, &count) default: count = atomic.LoadInt64(&RushStatus.Ios.PushSuccess) } @@ -206,9 +206,9 @@ func getIosError() int64 { case "memory": count = atomic.LoadInt64(&RushStatus.Ios.PushError) case "redis": - getRedisInt64Result(gorushIosError, &count) + getRedisInt64Result(IosErrorKey, &count) case "boltdb": - boltdbGet(gorushIosError, &count) + boltdbGet(IosErrorKey, &count) default: count = atomic.LoadInt64(&RushStatus.Ios.PushError) } @@ -222,9 +222,9 @@ func getAndroidSuccess() int64 { case "memory": count = atomic.LoadInt64(&RushStatus.Android.PushSuccess) case "redis": - getRedisInt64Result(gorushAndroidSuccess, &count) + getRedisInt64Result(AndroidSuccessKey, &count) case "boltdb": - boltdbGet(gorushAndroidSuccess, &count) + boltdbGet(AndroidSuccessKey, &count) default: count = atomic.LoadInt64(&RushStatus.Android.PushSuccess) } @@ -238,9 +238,9 @@ func getAndroidError() int64 { case "memory": count = atomic.LoadInt64(&RushStatus.Android.PushError) case "redis": - getRedisInt64Result(gorushAndroidError, &count) + getRedisInt64Result(AndroidErrorKey, &count) case "boltdb": - boltdbGet(gorushAndroidError, &count) + boltdbGet(AndroidErrorKey, &count) default: count = atomic.LoadInt64(&RushStatus.Android.PushError) } diff --git a/storage/redis/redis.go b/storage/redis/redis.go index 5deb3ac..d17343a 100644 --- a/storage/redis/redis.go +++ b/storage/redis/redis.go @@ -7,14 +7,6 @@ import ( "strconv" ) -const ( - gorushTotalCount = "gorush-total-count" - gorushIosSuccess = "gorush-ios-success-count" - gorushIosError = "gorush-ios-error-count" - gorushAndroidSuccess = "gorush-android-success-count" - gorushAndroidError = "gorush-android-error-count" -) - var RedisClient *redis.Client // Storage implements the storage interface for gorush (https://github.com/appleboy/gorush) @@ -61,56 +53,56 @@ func (s *Storage) initRedis() error { } func (s *Storage) addTotalCount(count int64) { - RedisClient.Set(gorushTotalCount, strconv.Itoa(int(count)), 0) + RedisClient.Set(gorush.TotalCountKey, strconv.Itoa(int(count)), 0) } func (s *Storage) addIosSuccess(count int64) { - RedisClient.Set(gorushIosSuccess, strconv.Itoa(int(count)), 0) + RedisClient.Set(gorush.IosSuccessKey, strconv.Itoa(int(count)), 0) } func (s *Storage) addIosError(count int64) { - RedisClient.Set(gorushIosError, strconv.Itoa(int(count)), 0) + RedisClient.Set(gorush.IosErrorKey, strconv.Itoa(int(count)), 0) } func (s *Storage) addAndroidSuccess(count int64) { - RedisClient.Set(gorushAndroidSuccess, strconv.Itoa(int(count)), 0) + RedisClient.Set(gorush.AndroidSuccessKey, strconv.Itoa(int(count)), 0) } func (s *Storage) addAndroidError(count int64) { - RedisClient.Set(gorushAndroidError, strconv.Itoa(int(count)), 0) + RedisClient.Set(gorush.AndroidErrorKey, strconv.Itoa(int(count)), 0) } func (s *Storage) getTotalCount() int64 { var count int64 - getRedisInt64Result(gorushTotalCount, &count) + getRedisInt64Result(gorush.TotalCountKey, &count) return count } func (s *Storage) getIosSuccess() int64 { var count int64 - getRedisInt64Result(gorushIosSuccess, &count) + getRedisInt64Result(gorush.IosSuccessKey, &count) return count } func (s *Storage) getIosError() int64 { var count int64 - getRedisInt64Result(gorushIosError, &count) + getRedisInt64Result(gorush.IosErrorKey, &count) return count } func (s *Storage) getAndroidSuccess() int64 { var count int64 - getRedisInt64Result(gorushAndroidSuccess, &count) + getRedisInt64Result(gorush.AndroidSuccessKey, &count) return count } func (s *Storage) getAndroidError() int64 { var count int64 - getRedisInt64Result(gorushAndroidError, &count) + getRedisInt64Result(gorush.AndroidErrorKey, &count) return count }