Documentation ¶
Overview ¶
Package storage holds interface and Redis implementation for messages storage in case producer is not currently available.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrStorageIsEmpty is an error raised in case when there are no more messages in the storage ErrStorageIsEmpty = errors.New("No more messages in storage") // ErrUnknownStorage is an error raised in case when trying to instantiate storage of unknown type ErrUnknownStorage = errors.New("Unknown storage type") // ErrRedisKeyMissed is an error raised when 'key' parameter is missing for redis storage type ErrRedisKeyMissed = errors.New("Redis storage requires 'key' parameter") )
Functions ¶
This section is empty.
Types ¶
type PersistentStorage ¶
type PersistentStorage interface { // Put writes data to persistent storage Put(data []byte) error // Get reads data from persistent storage, if no more data in the storage "ErrStorageIsEmpty" is returned Get() ([]byte, error) // Close closes connection to persistent storage Close() error }
PersistentStorage is an interface for persistent storage
func NewPersistentStorage ¶
func NewPersistentStorage(dsn *url.URL) (PersistentStorage, error)
NewPersistentStorage instantiates and establishes connection to persistent storage of given type
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
RedisStorage is a PersistentStorage interface implementation for Redis DB
func NewRedisStorage ¶
func NewRedisStorage(dsn *url.URL, key string) (*RedisStorage, error)
NewRedisStorage instantiates and establishes connection to Redis storage
func (*RedisStorage) Get ¶
func (s *RedisStorage) Get() ([]byte, error)
Get reads data from redis, if no more data in the storage "ErrStorageIsEmpty" is returned
Click to show internal directories.
Click to hide internal directories.