storage

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT-0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetPerRoomLimit

func SetPerRoomLimit(limit int)

Types

type Directory

type Directory struct {
	Path string
}

Directory store messages in local directory

func CreateDirectoryStorage

func CreateDirectoryStorage(path string) *Directory

func (*Directory) Count

func (directory *Directory) Count(room Room) int

func (*Directory) Delete

func (directory *Directory) Delete(room Room, messageId dto.MessageID) error

func (*Directory) DeleteRoom

func (directory *Directory) DeleteRoom(room Room) error

func (*Directory) List

func (directory *Directory) List(room Room, query SearchQuery, offset, limit int) ([]dto.Message, int, error)

func (*Directory) Load

func (directory *Directory) Load(room Room, messageId dto.MessageID) (*dto.Message, error)

func (*Directory) RoomDirectory

func (directory *Directory) RoomDirectory(room Room) string

RoomDirectory create correct path to specific `room`

func (*Directory) RoomsCount

func (directory *Directory) RoomsCount() int

func (*Directory) RoomsList

func (directory *Directory) RoomsList(offset, limit int) ([]Room, error)

func (*Directory) Store

func (directory *Directory) Store(room Room, message *dto.Message) (dto.MessageID, error)

type Room

type Room = string

type SearchQuery

type SearchQuery = map[string]string

type Storage

type Storage interface {
	// Store `message` to specific `room`
	Store(room Room, message *dto.Message) (dto.MessageID, error)
	// List retrieve list of messages based on `query` starting with `offset` index and count limited by `limit`
	// `query` - represents of key->value map, where key is search parameter
	List(room Room, query SearchQuery, offset, limit int) ([]dto.Message, int, error)
	// Count total messages in storage
	Count(room Room) int
	// Delete delete specific message from storage by `messageId`
	Delete(room Room, messageId dto.MessageID) error
	// Load find specific message from storage by `messageId`
	Load(room Room, messageId dto.MessageID) (*dto.Message, error)

	// RoomsList returns list of rooms in system
	RoomsList(offset, limit int) ([]Room, error)
	// RoomsCount total count rooms in storage
	RoomsCount() int
	// DeleteRoom delete all messages in room from storage
	DeleteRoom(room Room) error
}

Storage interface represents a backend flow to store or retrieve messages

Jump to

Keyboard shortcuts

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