Skip to content

Commit

Permalink
refactor: ensure all storage backends implement core.Storage
Browse files Browse the repository at this point in the history
- Add import for `github.com/appleboy/gorush/core` in all storage backends
- Add type assertion to ensure `Storage` implements `core.Storage` in all storage backends

Signed-off-by: appleboy <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Jun 22, 2024
1 parent c4fc985 commit f8eb352
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions storage/boltdb/boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import (
"os"
"sync"

"github.com/appleboy/gorush/core"

"github.com/asdine/storm/v3"
)

var _ core.Storage = (*Storage)(nil)

// New func implements the storage interface for gorush (https://github.com/appleboy/gorush)
func New(dbPath, bucket string) *Storage {
return &Storage{
Expand Down
4 changes: 4 additions & 0 deletions storage/buntdb/buntdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import (
"strconv"
"sync"

"github.com/appleboy/gorush/core"

"github.com/tidwall/buntdb"
)

var _ core.Storage = (*Storage)(nil)

// New func implements the storage interface for gorush (https://github.com/appleboy/gorush)
func New(dbPath string) *Storage {
return &Storage{
Expand Down
4 changes: 4 additions & 0 deletions storage/leveldb/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import (
"strconv"
"sync"

"github.com/appleboy/gorush/core"

"github.com/syndtr/goleveldb/leveldb"
)

var _ core.Storage = (*Storage)(nil)

func (s *Storage) setLevelDB(key string, count int64) {
value := fmt.Sprintf("%d", count)
_ = s.db.Put([]byte(key), []byte(value), nil)
Expand Down
4 changes: 4 additions & 0 deletions storage/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ package memory
import (
"sync"

"github.com/appleboy/gorush/core"

"go.uber.org/atomic"
)

var _ core.Storage = (*Storage)(nil)

// New func implements the storage interface for gorush (https://github.com/appleboy/gorush)
func New() *Storage {
return &Storage{}
Expand Down
4 changes: 4 additions & 0 deletions storage/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import (
"strconv"
"strings"

"github.com/appleboy/gorush/core"

"github.com/redis/go-redis/v9"
)

var _ core.Storage = (*Storage)(nil)

// New func implements the storage interface for gorush (https://github.com/appleboy/gorush)
func New(
addr string,
Expand Down

0 comments on commit f8eb352

Please sign in to comment.