1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

storage: Message refactoring for #69

- Message interface renamed to StoreMessage
- Message.Delete becomes Store.RemoveMessage
- Added deleted message tracking to Store stub for #80
This commit is contained in:
James Hillyerd
2018-03-11 15:01:40 -07:00
parent 12ad0cb3f0
commit 487e491d6f
11 changed files with 190 additions and 118 deletions

View File

@@ -12,27 +12,29 @@ import (
)
var (
// ErrNotExist indicates the requested message does not exist
ErrNotExist = errors.New("Message does not exist")
// ErrNotExist indicates the requested message does not exist.
ErrNotExist = errors.New("message does not exist")
// ErrNotWritable indicates the message is closed; no longer writable
ErrNotWritable = errors.New("Message not writable")
)
// Store is an interface to get Mailboxes stored in Inbucket
// Store is the interface Inbucket uses to interact with storage implementations.
type Store interface {
GetMessage(mailbox string, id string) (Message, error)
GetMessages(mailbox string) ([]Message, error)
GetMessage(mailbox, id string) (StoreMessage, error)
GetMessages(mailbox string) ([]StoreMessage, error)
PurgeMessages(mailbox string) error
VisitMailboxes(f func([]Message) (cont bool)) error
RemoveMessage(mailbox, id string) error
VisitMailboxes(f func([]StoreMessage) (cont bool)) error
// LockFor is a temporary hack to fix #77 until Datastore revamp
LockFor(emailAddress string) (*sync.RWMutex, error)
// NewMessage is temproary until #69 MessageData refactor
NewMessage(mailbox string) (Message, error)
NewMessage(mailbox string) (StoreMessage, error)
}
// Message is an interface for a single message in a Mailbox
type Message interface {
// StoreMessage represents a message to be stored, or returned from a storage implementation.
type StoreMessage interface {
Mailbox() string
ID() string
From() string
To() []string
@@ -44,7 +46,6 @@ type Message interface {
ReadRaw() (raw *string, err error)
Append(data []byte) error
Close() error
Delete() error
String() string
Size() int64
}