storage

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT-0 Imports: 16 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 smtpMessage.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) ([]smtpMessage.SMTPMail, int, error)

func (*Directory) Load

func (directory *Directory) Load(room Room, messageId smtpMessage.MessageID) (*smtpMessage.SMTPMail, 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 *smtpMessage.SMTPMail) (smtpMessage.MessageID, error)

type Message added in v1.0.16

type Message struct {
	ID      smtpMessage.MessageID    `bson:"id"`
	Room    string                   `bson:"room"`
	From    []*mail.Address          `bson:"from"`
	To      []*mail.Address          `bson:"to"`
	Subject string                   `bson:"subject"`
	Date    time.Time                `bson:"date"`
	Message *smtpMessage.SMTPMessage `bson:"message"`
}

type Mongo added in v1.0.16

type Mongo struct {
	Collection *mongo.Collection
}

func CreateMongoDbStorage added in v1.0.16

func CreateMongoDbStorage(collection *mongo.Collection) *Mongo

func (*Mongo) Count added in v1.0.16

func (mongoClient *Mongo) Count(room Room) int

func (*Mongo) Delete added in v1.0.16

func (mongoClient *Mongo) Delete(room Room, messageId smtpMessage.MessageID) error

func (*Mongo) DeleteRoom added in v1.0.16

func (mongoClient *Mongo) DeleteRoom(room Room) error

func (*Mongo) List added in v1.0.16

func (mongoClient *Mongo) List(room Room, query SearchQuery, offset, limit int) ([]smtpMessage.SMTPMail, int, error)

func (*Mongo) Load added in v1.0.16

func (mongoClient *Mongo) Load(room Room, messageId smtpMessage.MessageID) (*smtpMessage.SMTPMail, error)

func (*Mongo) RoomName added in v1.0.16

func (mongoClient *Mongo) RoomName(room Room) string

func (*Mongo) RoomsCount added in v1.0.16

func (mongoClient *Mongo) RoomsCount() int

func (*Mongo) RoomsList added in v1.0.16

func (mongoClient *Mongo) RoomsList(offset, limit int) ([]Room, error)

func (*Mongo) Store added in v1.0.16

func (mongoClient *Mongo) Store(room Room, message *smtpMessage.SMTPMail) (smtpMessage.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 *smtpMessage.SMTPMail) (smtpMessage.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) ([]smtpMessage.SMTPMail, int, error)
	// Count total messages in storage
	Count(room Room) int
	// Delete delete specific message from storage by `messageId`
	Delete(room Room, messageId smtpMessage.MessageID) error
	// Load find specific message from storage by `messageId`
	Load(room Room, messageId smtpMessage.MessageID) (*smtpMessage.SMTPMail, 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