1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

queue: Implement persistency

This patch makes the queue read and write items to disk.

It uses protobuf for serialization. We serialize to text format to make
manual troubleshooting easier, as the performance difference is not very
relevant for us.
This commit is contained in:
Alberto Bertogli
2016-09-18 06:13:42 +01:00
parent 9ed30a747b
commit aacf8ffea7
11 changed files with 457 additions and 64 deletions

View File

@@ -103,6 +103,8 @@ func main() {
// as a remote domain (for loops, alias resolutions, etc.).
s.AddDomain("localhost")
s.LoadQueue(conf.DataDir + "/queue")
// Load the addresses and listeners.
systemdLs, err := systemd.Listeners()
if err != nil {
@@ -249,6 +251,15 @@ func (s *Server) AddUserDB(domain string, db *userdb.DB) {
s.userDBs[domain] = db
}
func (s *Server) LoadQueue(path string) {
q := queue.New(path, s.localDomains)
err := q.Load()
if err != nil {
glog.Fatalf("Error loading queue: %v", err)
}
s.queue = q
}
func (s *Server) getTLSConfig() (*tls.Config, error) {
var err error
conf := &tls.Config{}
@@ -275,11 +286,6 @@ func (s *Server) ListenAndServe() {
glog.Fatalf("Error loading TLS config: %v", err)
}
// TODO: Create the queue when creating the server?
// Or even before, and just give it to the server?
s.queue = queue.New(
&courier.Procmail{}, &courier.SMTP{}, s.localDomains)
for m, addrs := range s.addrs {
for _, addr := range addrs {
// Listen.