Documentation ¶
Index ¶
- func Extract(mboxrd io.Reader, messages chan chan string, errors chan error)
- func TimeFromLine(line string, lc *time.Location) (string, error)
- func TimeNorm(line string, loc *time.Location) (string, error)
- func UnpackMessage(eml string, errors chan error, wg *sync.WaitGroup)
- func WriteOriginal(message chan string, emlName chan string, errors chan error, dir string, ...)
- type ByLineAdmit
- type ByLineName
- type Criterion
- type MboxError
- type MessageError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
Extract processes all lines from the the mboxrd reader and puts resulting messages each as its own channel into the provided messages channel.
It will stop only if it runs into non-empty lines prior to a message header. Otherwise it will continue processing the lines in assumption that the message archive format is correct.
Each message's channel and the parent messages' channel are closed after the mbox data is exhausted.
func WriteOriginal ¶
func WriteOriginal( message chan string, emlName chan string, errors chan error, dir string, admit ByLineAdmit, name ByLineName, wg *sync.WaitGroup)
WriteOriginal receives a message text from the `message` channel and writes it into a file in the destination `dir` directory.
All error are posted in the `error` parameter channel.
An `admit` parameter allows to determine if the message is left in the target directory. The function is called for each line in the message, uncluding headers. The value returned by the `admit` function determines if the message is kept in the directory.
The message file name is constructed by the `name` parameter function. The function is called for each line in the message, uncluding headers, until it returns a non-empty string. If `name` parameter is `nill` then messages will stay in randomly named temporary files starting with `_msg_` prefix
The `WaitGroup` parameter must be properly initialised and incremented prior to calling this function, or be supplied as `nil` if not needed.
Types ¶
type ByLineAdmit ¶
func AdmitAnyPattern ¶
func AdmitAnyPattern(criteria []Criterion, vetos []Criterion, errors chan error) ByLineAdmit
func AllWith ¶
func AllWith(addrs []string, errors chan error) ByLineAdmit
type ByLineName ¶
func NameFromTimeUser ¶
func NameFromTimeUser(format string, errors chan error) ByLineName
NameFromTimeUser returns a closed function used to extract a message file name based on the message timestamp and sender's username part of the email.
It is an example on how to construct the file name from multiple headers.
type MboxError ¶
type MboxError string
MboxError type is returned when there are errors occurred reading or splitting a mboxrd archive.
type MessageError ¶
type MessageError string
MessageError type is returned when there are errors occurred writing a mesage to filesystem.
func (MessageError) Error ¶
func (msge MessageError) Error() string