storage

package
v0.0.0-...-d3f719c Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConflict = errors.New("data conflict")
	ErrNotFound = errors.New("not found")
)

ErrConflict indicates a data conflict in the store.

Functions

This section is empty.

Types

type Keeper

type Keeper interface {
	LoadMessages(context.Context) (StorageMessage, error)
	InsertMessage(context.Context, models.Message) (int, error)
	GetMessages(context.Context, models.Filter, models.Pagination) ([]models.Message, error)
	UpdateMessagesProcessed(ctx context.Context, ids []int) error
	Ping(context.Context) bool
	Close() bool
}

Keeper interface for database operations

type Log

type Log interface {
	Info(string, ...zap.Field)
}

type MemoryStorage

type MemoryStorage struct {
	// contains filtered or unexported fields
}

MemoryStorage represents an in-memory storage with locking mechanisms

func NewMemoryStorage

func NewMemoryStorage(ctx context.Context, keeper Keeper, log Log) *MemoryStorage

NewMemoryStorage creates a new MemoryStorage instance

func (*MemoryStorage) GetMessages

func (s *MemoryStorage) GetMessages(ctx context.Context, filter models.Filter, pagination models.Pagination) ([]models.Message, error)

GetMessages retrieves processed messages from the database based on the provided filter and pagination

func (*MemoryStorage) InsertMessage

func (s *MemoryStorage) InsertMessage(ctx context.Context, message models.Message) error

InsertMessage inserts a new message into the storage and database

func (*MemoryStorage) UpdateMessagesProcessed

func (s *MemoryStorage) UpdateMessagesProcessed(ctx context.Context, ids []int) error

UpdateMessagesProcessed updates the processed status of messages in the database

type StorageMessage

type StorageMessage = map[int]models.Message

Jump to

Keyboard shortcuts

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