storage

package
v0.0.0-...-17e35b8 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionInformation

type ConnectionInformation struct {
	Address  string
	Port     int
	Database string
	UserName string
	Password string
	Filename string
}

ConnectionInformation contains data necessary to establish a connection to a database server.

func NewConnectionInformation

func NewConnectionInformation(address string, port int) *ConnectionInformation

NewConnectionInformation returns a new ConnectionInformation structure with the address and port filled in.

func (*ConnectionInformation) SetDatabaseFile

func (information *ConnectionInformation) SetDatabaseFile(filename string)

SetDatabaseFile sets the name of a file-base database. This is used for SQLite

func (*ConnectionInformation) SetDatabaseInformation

func (information *ConnectionInformation) SetDatabaseInformation(database, userName, password string)

SetDatabaseInformation fills in the name of a database to connect to, and the user credentials necessary to do so

type IStorage

type IStorage interface {
	Connect() error
	Disconnect()
	Create() error

	GetAttachment(mailID, attachmentID string) (attachment.Attachment, error)
	GetMailByID(id string) (mailitem.MailItem, error)
	GetMailCollection(offset, length int, mailSearch *search.MailSearch) ([]mailitem.MailItem, error)
	GetMailCount(mailSearch *search.MailSearch) (int, error)

	DeleteMailsAfterDate(startDate string) error
	StoreMail(mailItem *mailitem.MailItem) (string, error)
}

IStorage defines an interface for structures that need to connect to storage engines. They store and retrieve data for MailSlurper

func ConnectToStorage

func ConnectToStorage(storageType StorageType, connectionInfo *ConnectionInformation) (IStorage, error)

ConnectToStorage establishes a connection to the configured database engine and returns an object.

type MSSQLStorage

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

MSSQLStorage implements the IStorage interface

func NewMSSQLStorage

func NewMSSQLStorage(connectionInformation *ConnectionInformation) *MSSQLStorage

NewMSSQLStorage creates a new storage object that interfaces to MSSQL

func (*MSSQLStorage) Connect

func (storage *MSSQLStorage) Connect() error

Connect to the database

func (*MSSQLStorage) Create

func (storage *MSSQLStorage) Create() error

func (*MSSQLStorage) DeleteMailsAfterDate

func (storage *MSSQLStorage) DeleteMailsAfterDate(startDate string) error

DeleteMailsAfterDate deletes all mails after a specified date

func (*MSSQLStorage) Disconnect

func (storage *MSSQLStorage) Disconnect()

Disconnect does exactly what you think it does

func (*MSSQLStorage) GetAttachment

func (storage *MSSQLStorage) GetAttachment(mailID, attachmentID string) (attachment.Attachment, error)

GetAttachment retrieves an attachment for a given mail item

func (*MSSQLStorage) GetMailByID

func (storage *MSSQLStorage) GetMailByID(mailItemID string) (mailitem.MailItem, error)

GetMailByID retrieves a single mail item and attachment by ID

func (*MSSQLStorage) GetMailCollection

func (storage *MSSQLStorage) GetMailCollection(offset, length int, mailSearch *search.MailSearch) ([]mailitem.MailItem, error)

GetMailCollection retrieves a slice of mail items starting at offset and getting length number of records. This query is MSSQL 2005 and higher compatible.

func (*MSSQLStorage) GetMailCount

func (storage *MSSQLStorage) GetMailCount(mailSearch *search.MailSearch) (int, error)

GetMailCount returns the number of total records in the mail items table

func (*MSSQLStorage) StoreMail

func (storage *MSSQLStorage) StoreMail(mailItem *mailitem.MailItem) (string, error)

StoreMail writes a mail item and its attachments to the storage device. This returns the new mail ID

type MySQLStorage

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

MySQLStorage implements the IStorage interface

func NewMySQLStorage

func NewMySQLStorage(connectionInformation *ConnectionInformation) *MySQLStorage

MySQLStorage creates a new storage object that interfaces to MySQL

func (*MySQLStorage) Connect

func (storage *MySQLStorage) Connect() error

Connect to the database

func (*MySQLStorage) Create

func (storage *MySQLStorage) Create() error

func (*MySQLStorage) DeleteMailsAfterDate

func (storage *MySQLStorage) DeleteMailsAfterDate(startDate string) error

DeleteMailsAfterDate deletes all mails after a specified date

func (*MySQLStorage) Disconnect

func (storage *MySQLStorage) Disconnect()

Disconnect does exactly what you think it does

func (*MySQLStorage) GetAttachment

func (storage *MySQLStorage) GetAttachment(mailID, attachmentID string) (attachment.Attachment, error)

GetAttachment retrieves an attachment for a given mail item

func (*MySQLStorage) GetMailByID

func (storage *MySQLStorage) GetMailByID(mailItemID string) (mailitem.MailItem, error)

GetMailByID retrieves a single mail item and attachment by ID

func (*MySQLStorage) GetMailCollection

func (storage *MySQLStorage) GetMailCollection(offset, length int, mailSearch *search.MailSearch) ([]mailitem.MailItem, error)

GetMailCollection retrieves a slice of mail items starting at offset and getting length number of records. This query is MSSQL 2005 and higher compatible.

func (*MySQLStorage) GetMailCount

func (storage *MySQLStorage) GetMailCount(mailSearch *search.MailSearch) (int, error)

GetMailCount returns the number of total records in the mail items table

func (*MySQLStorage) StoreMail

func (storage *MySQLStorage) StoreMail(mailItem *mailitem.MailItem) (string, error)

StoreMail writes a mail item and its attachments to the storage device. This returns the new mail ID

type SQLiteStorage

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

SQLiteStorage implements the IStorage interface

func NewSQLiteStorage

func NewSQLiteStorage(connectionInformation *ConnectionInformation) *SQLiteStorage

NewSQLiteStorage creates a new storage object that interfaces to SQLite

func (*SQLiteStorage) Connect

func (storage *SQLiteStorage) Connect() error

Connect to the database

func (*SQLiteStorage) Create

func (storage *SQLiteStorage) Create() error

func (*SQLiteStorage) DeleteMailsAfterDate

func (storage *SQLiteStorage) DeleteMailsAfterDate(startDate string) error

DeleteMailsAfterDate deletes all mails after a specified date

func (*SQLiteStorage) Disconnect

func (storage *SQLiteStorage) Disconnect()

Disconnect does exactly what you think it does

func (*SQLiteStorage) GetAttachment

func (storage *SQLiteStorage) GetAttachment(mailID, attachmentID string) (attachment.Attachment, error)

GetAttachment retrieves an attachment for a given mail item

func (*SQLiteStorage) GetMailByID

func (storage *SQLiteStorage) GetMailByID(mailItemID string) (mailitem.MailItem, error)

GetMailByID retrieves a single mail item and attachment by ID

func (*SQLiteStorage) GetMailCollection

func (storage *SQLiteStorage) GetMailCollection(offset, length int, mailSearch *search.MailSearch) ([]mailitem.MailItem, error)

GetMailCollection retrieves a slice of mail items starting at offset and getting length number of records. This query is MSSQL 2005 and higher compatible.

func (*SQLiteStorage) GetMailCount

func (storage *SQLiteStorage) GetMailCount(mailSearch *search.MailSearch) (int, error)

GetMailCount returns the number of total records in the mail items table

func (*SQLiteStorage) StoreMail

func (storage *SQLiteStorage) StoreMail(mailItem *mailitem.MailItem) (string, error)

StoreMail writes a mail item and its attachments to the storage device. This returns the new mail ID

type StorageType

type StorageType int

StorageType defines types of database engines MailSlurper supports

const (
	STORAGE_MSSQL StorageType = iota
	STORAGE_SQLITE
	STORAGE_MYSQL
)

Jump to

Keyboard shortcuts

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