Documentation ¶
Overview ¶
Package datastore contains implementation independent datastore logic
Index ¶
- Variables
- type DataStore
- type HashLock
- type Mailbox
- type Message
- type MockDataStore
- type MockMailbox
- type MockMessage
- func (m *MockMessage) Append(data []byte) error
- func (m *MockMessage) Close() error
- func (m *MockMessage) Date() time.Time
- func (m *MockMessage) Delete() error
- func (m *MockMessage) From() string
- func (m *MockMessage) ID() string
- func (m *MockMessage) RawReader() (reader io.ReadCloser, err error)
- func (m *MockMessage) ReadBody() (body *enmime.Envelope, err error)
- func (m *MockMessage) ReadHeader() (msg *mail.Message, err error)
- func (m *MockMessage) ReadRaw() (raw *string, err error)
- func (m *MockMessage) Size() int64
- func (m *MockMessage) String() string
- func (m *MockMessage) Subject() string
- func (m *MockMessage) To() []string
- type RetentionScanner
Constants ¶
This section is empty.
Variables ¶
var ( // 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") )
Functions ¶
This section is empty.
Types ¶
type DataStore ¶
type DataStore interface { MailboxFor(emailAddress string) (Mailbox, error) AllMailboxes() ([]Mailbox, error) // LockFor is a temporary hack to fix #77 until Datastore revamp LockFor(emailAddress string) (*sync.RWMutex, error) }
DataStore is an interface to get Mailboxes stored in Inbucket
type Mailbox ¶
type Mailbox interface { GetMessages() ([]Message, error) GetMessage(id string) (Message, error) Purge() error NewMessage() (Message, error) Name() string String() string }
Mailbox is an interface to get and manipulate messages in a DataStore
type Message ¶
type Message interface { ID() string From() string To() []string Date() time.Time Subject() string RawReader() (reader io.ReadCloser, err error) ReadHeader() (msg *mail.Message, err error) ReadBody() (body *enmime.Envelope, err error) ReadRaw() (raw *string, err error) Append(data []byte) error Close() error Delete() error String() string Size() int64 }
Message is an interface for a single message in a Mailbox
type MockDataStore ¶
MockDataStore is a shared mock for unit testing
func (*MockDataStore) AllMailboxes ¶
func (m *MockDataStore) AllMailboxes() ([]Mailbox, error)
AllMailboxes mock function
func (*MockDataStore) LockFor ¶ added in v1.3.1
func (m *MockDataStore) LockFor(name string) (*sync.RWMutex, error)
func (*MockDataStore) MailboxFor ¶
func (m *MockDataStore) MailboxFor(name string) (Mailbox, error)
MailboxFor mock function
type MockMailbox ¶
MockMailbox is a shared mock for unit testing
func (*MockMailbox) GetMessage ¶
func (m *MockMailbox) GetMessage(id string) (Message, error)
GetMessage mock function
func (*MockMailbox) GetMessages ¶
func (m *MockMailbox) GetMessages() ([]Message, error)
GetMessages mock function
func (*MockMailbox) NewMessage ¶
func (m *MockMailbox) NewMessage() (Message, error)
NewMessage mock function
type MockMessage ¶
MockMessage is a shared mock for unit testing
func (*MockMessage) RawReader ¶
func (m *MockMessage) RawReader() (reader io.ReadCloser, err error)
RawReader mock function
func (*MockMessage) ReadBody ¶
func (m *MockMessage) ReadBody() (body *enmime.Envelope, err error)
ReadBody mock function
func (*MockMessage) ReadHeader ¶
func (m *MockMessage) ReadHeader() (msg *mail.Message, err error)
ReadHeader mock function
func (*MockMessage) ReadRaw ¶
func (m *MockMessage) ReadRaw() (raw *string, err error)
ReadRaw mock function
type RetentionScanner ¶
type RetentionScanner struct {
// contains filtered or unexported fields
}
RetentionScanner looks for messages older than the configured retention period and deletes them.
func NewRetentionScanner ¶
func NewRetentionScanner(ds DataStore, shutdownChannel chan bool) *RetentionScanner
NewRetentionScanner launches a go-routine that scans for expired messages, following the configured interval
func (*RetentionScanner) Join ¶
func (rs *RetentionScanner) Join()
Join does not retun until the retention scanner has shut down
func (*RetentionScanner) Start ¶
func (rs *RetentionScanner) Start()
Start up the retention scanner if retention period > 0