message driver storage
This commit is contained in:
22
storage.go
Normal file
22
storage.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import "context"
|
||||
|
||||
type Storage struct {
|
||||
driver Driver
|
||||
}
|
||||
|
||||
type Driver interface {
|
||||
Close() error
|
||||
ForEach(context.Context, func(string, []byte) error) error
|
||||
Get(context.Context, string) ([]byte, error)
|
||||
Set(context.Context, string, []byte) error
|
||||
}
|
||||
|
||||
func NewTestStorage() Storage {
|
||||
return Storage{driver: NewTestDB()}
|
||||
}
|
||||
|
||||
func NewStorage(driver Driver) Storage {
|
||||
return Storage{driver: driver}
|
||||
}
|
||||
Reference in New Issue
Block a user