storage

package
v0.2.3-0...-5ed8acd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 5 Imported by: 0

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) Close

func (s *RedisStorage) Close() error

Close closes connection to redis

func (*RedisStorage) Get

func (s *RedisStorage) Get() ([]byte, error)

Get reads data from redis, if no more data in the storage "ErrStorageIsEmpty" is returned

func (*RedisStorage) Put

func (s *RedisStorage) Put(data []byte) error

Put writes data to Redis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL