Documentation ¶
Index ¶
- Constants
- Variables
- func AddDeletedFlag(conn *imap.Client, uid uint32) error
- func AppendMessage(conn *imap.Client, messageData MessageData) error
- func CheckAndAppendMessages(dstConn *imap.Client, storeRequests chan WorkRequest, ...)
- func GetAllMessages(conn *imap.Client) (*imap.Command, error)
- func GetConnection(info InboxInfo, readOnly bool) (*imap.Client, error)
- func Idle(src *imap.Client, appendRequests []chan WorkRequest, requestPurge chan bool) (err error)
- func ResetConnection(conn *imap.Client, readOnly bool) error
- func SearchAndPurge(src []*imap.Client, dsts map[string][]*imap.Client) error
- func SearchAndStore(src []*imap.Client, dsts map[string][]*imap.Client, dbFile string, ...) (err error)
- func Sync(src []*imap.Client, dsts map[string][]*imap.Client, runPurge bool, ...) (err error)
- type Cache
- type Config
- type CopyCat
- type InboxInfo
- type MessageData
- type WorkRequest
Constants ¶
const ( MemcacheServer = "localhost:11211" NoopMinutes = 15 )
Variables ¶
var ErrNotFound = errors.New("not found")
our own so we dont have to include leveldb elsewhere
var NotFound = errors.New("message not found")
Functions ¶
func AppendMessage ¶
func AppendMessage(conn *imap.Client, messageData MessageData) error
func CheckAndAppendMessages ¶
func CheckAndAppendMessages(dstConn *imap.Client, storeRequests chan WorkRequest, fetchRequests chan fetchRequest, wg *sync.WaitGroup)
checkAndStoreMessages will wait for WorkRequests to come acorss the pipe. When it receives a request, it will search the given destination inbox for the message. If it is not found, this method will attempt to pull the messages data from fetchRequests and then append it to the destination.
func Idle ¶
func Idle(src *imap.Client, appendRequests []chan WorkRequest, requestPurge chan bool) (err error)
Idle setup the processes to wait for notifications from the IMAP source connection. If an EXISTS or EXPUNGE command comes across the pipe, the appropriate actions will be taken to update the destinations. If the process decides the inboxes are out of sync, it will pass a bool to the requestPurge channel. It is expected that the requestPurge channel is setup to initiate a purge process when it receives the notificaiton.
func SearchAndPurge ¶
SearchAndPurge will go through the destination inboxes and check if each message exists in the source inbox. If a message does not exist in the source, delete it from the destination.
func SearchAndStore ¶
func SearchAndStore(src []*imap.Client, dsts map[string][]*imap.Client, dbFile string, quickSyncCount int) (err error)
SearchAndStore will check check if each message in the source inbox exists in the destinations. If it doesn't exist in a destination, the message info will be pulled and stored into the destination.
Types ¶
type CopyCat ¶
type CopyCat struct { SyncConns conns IdleAppendConns conns IdlePurgeConns conns IdleConn *imap.Client }
CopyCat represents a process waiting to copy
func NewCopyCat ¶
func NewCopyCat(src InboxInfo, dsts []InboxInfo, connsPerInbox int, sync bool, idle bool) (cat *CopyCat, err error)
NewCopyCat will create a new CopyCat instance that has all of its expected connections for syncing and idling.
type InboxInfo ¶
func NewInboxInfo ¶
type MessageData ¶
func FetchMessage ¶
func FetchMessage(conn *imap.Client, messageUID uint32) (msg MessageData, err error)
type WorkRequest ¶
type WorkRequest struct { Value string Header string UID uint32 Msg MessageData }