datastore

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package datastore contains implementation independent datastore logic

Index

Constants

This section is empty.

Variables

View Source
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 HashLock added in v1.3.1

type HashLock [4096]sync.RWMutex

func (*HashLock) Get added in v1.3.1

func (h *HashLock) Get(hash string) *sync.RWMutex

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

type MockDataStore struct {
	mock.Mock
}

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

type MockMailbox struct {
	mock.Mock
}

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) Name

func (m *MockMailbox) Name() string

Name mock function

func (*MockMailbox) NewMessage

func (m *MockMailbox) NewMessage() (Message, error)

NewMessage mock function

func (*MockMailbox) Purge

func (m *MockMailbox) Purge() error

Purge mock function

func (*MockMailbox) String

func (m *MockMailbox) String() string

String mock function

type MockMessage

type MockMessage struct {
	mock.Mock
}

MockMessage is a shared mock for unit testing

func (*MockMessage) Append

func (m *MockMessage) Append(data []byte) error

Append mock function

func (*MockMessage) Close

func (m *MockMessage) Close() error

Close mock function

func (*MockMessage) Date

func (m *MockMessage) Date() time.Time

Date mock function

func (*MockMessage) Delete

func (m *MockMessage) Delete() error

Delete mock function

func (*MockMessage) From

func (m *MockMessage) From() string

From mock function

func (*MockMessage) ID

func (m *MockMessage) ID() string

ID mock function

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

func (*MockMessage) Size

func (m *MockMessage) Size() int64

Size mock function

func (*MockMessage) String

func (m *MockMessage) String() string

String mock function

func (*MockMessage) Subject

func (m *MockMessage) Subject() string

Subject mock function

func (*MockMessage) To

func (m *MockMessage) To() []string

To 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

Jump to

Keyboard shortcuts

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