gte/cmd/process-inbox/main.go

29 lines
714 B
Go
Raw Normal View History

2021-01-29 12:29:23 +01:00
package main
import (
"os"
2021-05-13 08:15:14 +02:00
"git.ewintr.nl/go-kit/log"
"git.ewintr.nl/gte/internal/process"
2021-05-13 09:47:06 +02:00
"git.ewintr.nl/gte/internal/task"
"git.ewintr.nl/gte/pkg/mstore"
2021-01-29 12:29:23 +01:00
)
func main() {
2021-05-13 08:15:14 +02:00
logger := log.New(os.Stdout).WithField("cmd", "process-inbox")
config := &mstore.IMAPConfig{
IMAPURL: os.Getenv("IMAP_URL"),
IMAPUsername: os.Getenv("IMAP_USERNAME"),
IMAPPassword: os.Getenv("IMAP_PASSWORD"),
2021-01-29 12:29:23 +01:00
}
2021-05-13 08:15:14 +02:00
msgStore := mstore.NewIMAP(config)
2021-01-29 12:29:23 +01:00
2021-05-13 08:15:14 +02:00
inboxProcessor := process.NewInbox(task.NewRepository(msgStore))
result, err := inboxProcessor.Process()
2021-01-29 12:29:23 +01:00
if err != nil {
2021-05-13 08:15:14 +02:00
logger.WithErr(err).Error("unable to process inbox")
os.Exit(1)
2021-01-29 19:40:46 +01:00
}
2021-05-13 08:15:14 +02:00
logger.WithField("count", result.Count).Info("finished processing inbox")
2021-01-29 12:29:23 +01:00
}