storage

package
v0.0.0-...-0776f63 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package storage provides implementations of storage interfaces.

Index

Constants

This section is empty.

Variables

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

ErrConflict indicates a data conflict in the store.

Functions

This section is empty.

Types

type Keeper

type Keeper interface {
	// UserExists checks if a user exists.
	UserExists(ctx context.Context, username string) (bool, error)
	// AddUser adds a new user to the storage.
	AddUser(ctx context.Context, username string, hashedPassword string) error
	// GetPassword retrieves the password for the given username.
	GetPassword(ctx context.Context, username string) (string, error)
	// GetUserID retrieves the user ID for the given username.
	GetUserID(ctx context.Context, username string) (int, error)
	// AddData adds data to the storage.
	AddData(ctx context.Context, table string, user_id int, entry_id string, data map[string]string) error
	// UpdateData updates existing data in the storage.
	UpdateData(ctx context.Context, table string, user_id int, entry_id string, data map[string]string) error
	// DeleteData deletes data from the storage.
	DeleteData(ctx context.Context, table string, user_id int, entry_id string) error
	// GetAllData retrieves all data from the storage.
	GetAllData(ctx context.Context, table string, user_id int, last_sync time.Time, incl_del bool) ([]map[string]string, error)
}

Keeper represents the storage keeper interface.

type Log

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

Log is an interface representing a logger with Info method.

type MemoryStorage

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

MemoryStorage is an in-memory storage implementation with CRUD operations for URL and user data.

func NewMemoryStorage

func NewMemoryStorage(keeper Keeper, log Log) *MemoryStorage

NewMemoryStorage creates a new MemoryStorage instance with the provided Keeper and logger.

func (*MemoryStorage) AddData

func (ms *MemoryStorage) AddData(ctx context.Context, table string, user_id int, entry_id string, data map[string]string) error

AddData adds data to the storage.

func (*MemoryStorage) AddUser

func (ms *MemoryStorage) AddUser(ctx context.Context, username string, hashedPassword string) error

AddUser adds a new user to the storage.

func (*MemoryStorage) DeleteData

func (ms *MemoryStorage) DeleteData(ctx context.Context, table string, user_id int, entry_id string) error

DeleteData deletes data from the storage.

func (*MemoryStorage) GetAllData

func (ms *MemoryStorage) GetAllData(ctx context.Context, table string, user_id int, last_sync time.Time, incl_del bool) ([]map[string]string, error)

GetAllData retrieves all data from the storage.

func (*MemoryStorage) GetPassword

func (ms *MemoryStorage) GetPassword(ctx context.Context, username string) (string, error)

GetPassword retrieves the password for the given username.

func (*MemoryStorage) GetUserID

func (ms *MemoryStorage) GetUserID(ctx context.Context, username string) (int, error)

GetUserID retrieves the user ID for the given username.

func (*MemoryStorage) UpdateData

func (ms *MemoryStorage) UpdateData(ctx context.Context, table string, user_id int, entry_id string, data map[string]string) error

UpdateData updates existing data in the storage.

func (*MemoryStorage) UserExists

func (ms *MemoryStorage) UserExists(ctx context.Context, username string) (bool, error)

UserExists checks if a user exists.

Jump to

Keyboard shortcuts

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