From dd1fb29e6b8a55329be1f843f6bc33315076c030 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 1 Aug 2016 10:57:00 +0800 Subject: [PATCH] fix boltdb and memory client lint. Signed-off-by: Bo-Yi Wu --- storage/boltdb/boltdb.go | 13 +++++++++++++ storage/memory/memory.go | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/storage/boltdb/boltdb.go b/storage/boltdb/boltdb.go index 0e069f4..74a5bde 100644 --- a/storage/boltdb/boltdb.go +++ b/storage/boltdb/boltdb.go @@ -21,14 +21,17 @@ func New(config config.ConfYaml) *Storage { } } +// Storage is interface structure type Storage struct { config config.ConfYaml } +// Init client storage. func (s *Storage) Init() error { return nil } +// Reset Client storage. func (s *Storage) Reset() { s.setBoltDB(TotalCountKey, 0) s.setBoltDB(IosSuccessKey, 0) @@ -49,31 +52,37 @@ func (s *Storage) getBoltDB(key string, count *int64) { defer db.Close() } +// AddTotalCount record push notification count. func (s *Storage) AddTotalCount(count int64) { total := s.GetTotalCount() + count s.setBoltDB(TotalCountKey, total) } +// AddIosSuccess record counts of success iOS push notification. func (s *Storage) AddIosSuccess(count int64) { total := s.GetIosSuccess() + count s.setBoltDB(IosSuccessKey, total) } +// AddIosError record counts of error iOS push notification. func (s *Storage) AddIosError(count int64) { total := s.GetIosError() + count s.setBoltDB(IosErrorKey, total) } +// AddAndroidSuccess record counts of success Android push notification. func (s *Storage) AddAndroidSuccess(count int64) { total := s.GetAndroidSuccess() + count s.setBoltDB(AndroidSuccessKey, total) } +// AddAndroidError record counts of error Android push notification. func (s *Storage) AddAndroidError(count int64) { total := s.GetAndroidError() + count s.setBoltDB(AndroidErrorKey, total) } +// GetTotalCount show counts of all notification. func (s *Storage) GetTotalCount() int64 { var count int64 s.getBoltDB(TotalCountKey, &count) @@ -81,6 +90,7 @@ func (s *Storage) GetTotalCount() int64 { return count } +// GetIosSuccess show success counts of iOS notification. func (s *Storage) GetIosSuccess() int64 { var count int64 s.getBoltDB(IosSuccessKey, &count) @@ -88,6 +98,7 @@ func (s *Storage) GetIosSuccess() int64 { return count } +// GetIosError show error counts of iOS notification. func (s *Storage) GetIosError() int64 { var count int64 s.getBoltDB(IosErrorKey, &count) @@ -95,6 +106,7 @@ func (s *Storage) GetIosError() int64 { return count } +// GetAndroidSuccess show success counts of Android notification. func (s *Storage) GetAndroidSuccess() int64 { var count int64 s.getBoltDB(AndroidSuccessKey, &count) @@ -102,6 +114,7 @@ func (s *Storage) GetAndroidSuccess() int64 { return count } +// GetAndroidError show error counts of Android notification. func (s *Storage) GetAndroidError() int64 { var count int64 s.getBoltDB(AndroidErrorKey, &count) diff --git a/storage/memory/memory.go b/storage/memory/memory.go index 75445bf..d8b689e 100644 --- a/storage/memory/memory.go +++ b/storage/memory/memory.go @@ -30,61 +30,74 @@ func New() *Storage { } } +// Storage is interface structure type Storage struct { stat *statApp } +// Init client storage. func (s *Storage) Init() error { return nil } +// Reset Client storage. func (s *Storage) Reset() { } +// AddTotalCount record push notification count. func (s *Storage) AddTotalCount(count int64) { atomic.AddInt64(&s.stat.TotalCount, count) } +// AddIosSuccess record counts of success iOS push notification. func (s *Storage) AddIosSuccess(count int64) { atomic.AddInt64(&s.stat.Ios.PushSuccess, count) } +// AddIosError record counts of error iOS push notification. func (s *Storage) AddIosError(count int64) { atomic.AddInt64(&s.stat.Ios.PushError, count) } +// AddAndroidSuccess record counts of success Android push notification. func (s *Storage) AddAndroidSuccess(count int64) { atomic.AddInt64(&s.stat.Android.PushSuccess, count) } +// AddAndroidError record counts of error Android push notification. func (s *Storage) AddAndroidError(count int64) { atomic.AddInt64(&s.stat.Android.PushError, count) } +// GetTotalCount show counts of all notification. func (s *Storage) GetTotalCount() int64 { count := atomic.LoadInt64(&s.stat.TotalCount) return count } +// GetIosSuccess show success counts of iOS notification. func (s *Storage) GetIosSuccess() int64 { count := atomic.LoadInt64(&s.stat.Ios.PushSuccess) return count } +// GetIosError show error counts of iOS notification. func (s *Storage) GetIosError() int64 { count := atomic.LoadInt64(&s.stat.Ios.PushError) return count } +// GetAndroidSuccess show success counts of Android notification. func (s *Storage) GetAndroidSuccess() int64 { count := atomic.LoadInt64(&s.stat.Android.PushSuccess) return count } +// GetAndroidError show error counts of Android notification. func (s *Storage) GetAndroidError() int64 { count := atomic.LoadInt64(&s.stat.Android.PushError)