backends

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Id      string
	Content string
}

type MessageProvider

type MessageProvider interface {
	LoadMessages() (messages []Message, err error)
	DeleteMessage(messageId string) (err error)
}

type SingleUserAuthenticator

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

func NewSingleUserAuthenticator

func NewSingleUserAuthenticator(user string, password string) SingleUserAuthenticator

func (SingleUserAuthenticator) Authorize

func (a SingleUserAuthenticator) Authorize(user, pass string) bool

type SingleUserBackend

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

func NewSingleUserBackend

func NewSingleUserBackend(messageProvider *MessageProvider, user string) SingleUserBackend

func (SingleUserBackend) Dele

func (i SingleUserBackend) Dele(user string, msgId int) error

Delete message by message ID - message should be just marked as deleted until Update() is called. Be aware that after Dele() is called, functions like List() etc. should ignore all these messages even if Update() hasn't been called yet

func (SingleUserBackend) List

func (i SingleUserBackend) List(user string) (octets []int, err error)

List of sizes of all messages in bytes (octets)

func (SingleUserBackend) ListMessage

func (i SingleUserBackend) ListMessage(user string, msgId int) (exists bool, octets int, err error)

Returns whether message exists and if yes, then return size of the message in bytes (octets)

func (SingleUserBackend) Lock

func (i SingleUserBackend) Lock(user string) error

Lock is called immediately after client is connected.

func (SingleUserBackend) Retr

func (i SingleUserBackend) Retr(user string, msgId int) (message string, err error)

Retrieve whole message by ID - note that message ID is a message position returned by List() function, so be sure to keep that order unchanged while client is connected See Lock() function for more details

func (SingleUserBackend) Rset

func (i SingleUserBackend) Rset(user string) error

Undelete all messages marked as deleted in single connection

func (SingleUserBackend) Stat

func (i SingleUserBackend) Stat(user string) (messages, octets int, err error)

Returns total message count and total mailbox size in bytes (octets). Deleted messages are ignored.

func (SingleUserBackend) Uidl

func (i SingleUserBackend) Uidl(user string) (uids []string, err error)

List of unique IDs of all message, similar to List(), but instead of size there is a unique ID which persists the same across all connections. Uid (unique id) is used to allow client to be able to keep messages on the server.

func (SingleUserBackend) UidlMessage

func (i SingleUserBackend) UidlMessage(user string, msgId int) (exists bool, uid string, err error)

Similar to ListMessage, but returns unique ID by message ID instead of size.

func (SingleUserBackend) Unlock

func (i SingleUserBackend) Unlock(user string) error

Release lock on storage, Unlock() is called after client is disconnected.

func (SingleUserBackend) Update

func (i SingleUserBackend) Update(user string) (err error)

Write all changes to persistent storage, i.e. delete all messages marked as deleted.

Jump to

Keyboard shortcuts

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