switch default private key to public.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-05-02 12:16:39 +08:00
parent a8851981c2
commit 9cfe693ad9
3 changed files with 35 additions and 43 deletions

View File

@ -21,9 +21,9 @@ const (
// Stat variable for redis // Stat variable for redis
const ( const (
gorushTotalCount = "gorush-total-count" TotalCountKey = "gorush-total-count"
gorushIosSuccess = "gorush-ios-success-count" IosSuccessKey = "gorush-ios-success-count"
gorushIosError = "gorush-ios-error-count" IosErrorKey = "gorush-ios-error-count"
gorushAndroidSuccess = "gorush-android-success-count" AndroidSuccessKey = "gorush-android-success-count"
gorushAndroidError = "gorush-android-error-count" AndroidErrorKey = "gorush-android-error-count"
) )

View File

@ -108,9 +108,9 @@ func addTotalCount(count int64) {
case "memory": case "memory":
atomic.AddInt64(&RushStatus.TotalCount, count) atomic.AddInt64(&RushStatus.TotalCount, count)
case "redis": case "redis":
RedisClient.Set(gorushTotalCount, strconv.Itoa(int(count)), 0) RedisClient.Set(TotalCountKey, strconv.Itoa(int(count)), 0)
case "boltdb": case "boltdb":
boltdbSet(gorushTotalCount, count) boltdbSet(TotalCountKey, count)
default: default:
atomic.AddInt64(&RushStatus.TotalCount, count) atomic.AddInt64(&RushStatus.TotalCount, count)
} }
@ -121,9 +121,9 @@ func addIosSuccess(count int64) {
case "memory": case "memory":
atomic.AddInt64(&RushStatus.Ios.PushSuccess, count) atomic.AddInt64(&RushStatus.Ios.PushSuccess, count)
case "redis": case "redis":
RedisClient.Set(gorushIosSuccess, strconv.Itoa(int(count)), 0) RedisClient.Set(IosSuccessKey, strconv.Itoa(int(count)), 0)
case "boltdb": case "boltdb":
boltdbSet(gorushIosSuccess, count) boltdbSet(IosSuccessKey, count)
default: default:
atomic.AddInt64(&RushStatus.Ios.PushSuccess, count) atomic.AddInt64(&RushStatus.Ios.PushSuccess, count)
} }
@ -134,9 +134,9 @@ func addIosError(count int64) {
case "memory": case "memory":
atomic.AddInt64(&RushStatus.Ios.PushError, count) atomic.AddInt64(&RushStatus.Ios.PushError, count)
case "redis": case "redis":
RedisClient.Set(gorushIosError, strconv.Itoa(int(count)), 0) RedisClient.Set(IosErrorKey, strconv.Itoa(int(count)), 0)
case "boltdb": case "boltdb":
boltdbSet(gorushIosError, count) boltdbSet(IosErrorKey, count)
default: default:
atomic.AddInt64(&RushStatus.Ios.PushError, count) atomic.AddInt64(&RushStatus.Ios.PushError, count)
} }
@ -147,9 +147,9 @@ func addAndroidSuccess(count int64) {
case "memory": case "memory":
atomic.AddInt64(&RushStatus.Android.PushSuccess, count) atomic.AddInt64(&RushStatus.Android.PushSuccess, count)
case "redis": case "redis":
RedisClient.Set(gorushAndroidSuccess, strconv.Itoa(int(count)), 0) RedisClient.Set(AndroidSuccessKey, strconv.Itoa(int(count)), 0)
case "boltdb": case "boltdb":
boltdbSet(gorushAndroidSuccess, count) boltdbSet(AndroidSuccessKey, count)
default: default:
atomic.AddInt64(&RushStatus.Android.PushSuccess, count) atomic.AddInt64(&RushStatus.Android.PushSuccess, count)
} }
@ -160,9 +160,9 @@ func addAndroidError(count int64) {
case "memory": case "memory":
atomic.AddInt64(&RushStatus.Android.PushError, count) atomic.AddInt64(&RushStatus.Android.PushError, count)
case "redis": case "redis":
RedisClient.Set(gorushAndroidError, strconv.Itoa(int(count)), 0) RedisClient.Set(AndroidErrorKey, strconv.Itoa(int(count)), 0)
case "boltdb": case "boltdb":
boltdbSet(gorushAndroidError, count) boltdbSet(AndroidErrorKey, count)
default: default:
atomic.AddInt64(&RushStatus.Android.PushError, count) atomic.AddInt64(&RushStatus.Android.PushError, count)
} }
@ -174,9 +174,9 @@ func getTotalCount() int64 {
case "memory": case "memory":
count = atomic.LoadInt64(&RushStatus.TotalCount) count = atomic.LoadInt64(&RushStatus.TotalCount)
case "redis": case "redis":
getRedisInt64Result(gorushTotalCount, &count) getRedisInt64Result(TotalCountKey, &count)
case "boltdb": case "boltdb":
boltdbGet(gorushTotalCount, &count) boltdbGet(TotalCountKey, &count)
default: default:
count = atomic.LoadInt64(&RushStatus.TotalCount) count = atomic.LoadInt64(&RushStatus.TotalCount)
} }
@ -190,9 +190,9 @@ func getIosSuccess() int64 {
case "memory": case "memory":
count = atomic.LoadInt64(&RushStatus.Ios.PushSuccess) count = atomic.LoadInt64(&RushStatus.Ios.PushSuccess)
case "redis": case "redis":
getRedisInt64Result(gorushIosSuccess, &count) getRedisInt64Result(IosSuccessKey, &count)
case "boltdb": case "boltdb":
boltdbGet(gorushIosSuccess, &count) boltdbGet(IosSuccessKey, &count)
default: default:
count = atomic.LoadInt64(&RushStatus.Ios.PushSuccess) count = atomic.LoadInt64(&RushStatus.Ios.PushSuccess)
} }
@ -206,9 +206,9 @@ func getIosError() int64 {
case "memory": case "memory":
count = atomic.LoadInt64(&RushStatus.Ios.PushError) count = atomic.LoadInt64(&RushStatus.Ios.PushError)
case "redis": case "redis":
getRedisInt64Result(gorushIosError, &count) getRedisInt64Result(IosErrorKey, &count)
case "boltdb": case "boltdb":
boltdbGet(gorushIosError, &count) boltdbGet(IosErrorKey, &count)
default: default:
count = atomic.LoadInt64(&RushStatus.Ios.PushError) count = atomic.LoadInt64(&RushStatus.Ios.PushError)
} }
@ -222,9 +222,9 @@ func getAndroidSuccess() int64 {
case "memory": case "memory":
count = atomic.LoadInt64(&RushStatus.Android.PushSuccess) count = atomic.LoadInt64(&RushStatus.Android.PushSuccess)
case "redis": case "redis":
getRedisInt64Result(gorushAndroidSuccess, &count) getRedisInt64Result(AndroidSuccessKey, &count)
case "boltdb": case "boltdb":
boltdbGet(gorushAndroidSuccess, &count) boltdbGet(AndroidSuccessKey, &count)
default: default:
count = atomic.LoadInt64(&RushStatus.Android.PushSuccess) count = atomic.LoadInt64(&RushStatus.Android.PushSuccess)
} }
@ -238,9 +238,9 @@ func getAndroidError() int64 {
case "memory": case "memory":
count = atomic.LoadInt64(&RushStatus.Android.PushError) count = atomic.LoadInt64(&RushStatus.Android.PushError)
case "redis": case "redis":
getRedisInt64Result(gorushAndroidError, &count) getRedisInt64Result(AndroidErrorKey, &count)
case "boltdb": case "boltdb":
boltdbGet(gorushAndroidError, &count) boltdbGet(AndroidErrorKey, &count)
default: default:
count = atomic.LoadInt64(&RushStatus.Android.PushError) count = atomic.LoadInt64(&RushStatus.Android.PushError)
} }

View File

@ -7,14 +7,6 @@ import (
"strconv" "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 var RedisClient *redis.Client
// Storage implements the storage interface for gorush (https://github.com/appleboy/gorush) // 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) { 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) { 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) { 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) { 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) { 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 { func (s *Storage) getTotalCount() int64 {
var count int64 var count int64
getRedisInt64Result(gorushTotalCount, &count) getRedisInt64Result(gorush.TotalCountKey, &count)
return count return count
} }
func (s *Storage) getIosSuccess() int64 { func (s *Storage) getIosSuccess() int64 {
var count int64 var count int64
getRedisInt64Result(gorushIosSuccess, &count) getRedisInt64Result(gorush.IosSuccessKey, &count)
return count return count
} }
func (s *Storage) getIosError() int64 { func (s *Storage) getIosError() int64 {
var count int64 var count int64
getRedisInt64Result(gorushIosError, &count) getRedisInt64Result(gorush.IosErrorKey, &count)
return count return count
} }
func (s *Storage) getAndroidSuccess() int64 { func (s *Storage) getAndroidSuccess() int64 {
var count int64 var count int64
getRedisInt64Result(gorushAndroidSuccess, &count) getRedisInt64Result(gorush.AndroidSuccessKey, &count)
return count return count
} }
func (s *Storage) getAndroidError() int64 { func (s *Storage) getAndroidError() int64 {
var count int64 var count int64
getRedisInt64Result(gorushAndroidError, &count) getRedisInt64Result(gorush.AndroidErrorKey, &count)
return count return count
} }