1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 09:37:02 +00:00

storage: Make type/params configurable for #88

This commit is contained in:
James Hillyerd
2018-03-24 13:18:51 -07:00
parent bb0fb410c1
commit 281cc21412
8 changed files with 53 additions and 18 deletions

View File

@@ -23,6 +23,7 @@ import (
"github.com/jhillyerd/inbucket/pkg/server/web"
"github.com/jhillyerd/inbucket/pkg/storage"
"github.com/jhillyerd/inbucket/pkg/storage/file"
"github.com/jhillyerd/inbucket/pkg/storage/mem"
"github.com/jhillyerd/inbucket/pkg/webui"
)
@@ -45,6 +46,10 @@ func init() {
expvar.Publish("goroutines", expvar.Func(func() interface{} {
return runtime.NumGoroutine()
}))
// Register storage implementations.
storage.Constructors["file"] = file.New
storage.Constructors["memory"] = mem.New
}
func main() {
@@ -97,8 +102,13 @@ func main() {
// Configure internal services.
rootCtx, rootCancel := context.WithCancel(context.Background())
shutdownChan := make(chan bool)
store, err := storage.FromConfig(conf.Storage)
if err != nil {
log.Errorf("Fatal storage error: %v", err)
removePIDFile(*pidfile)
os.Exit(1)
}
msgHub := msghub.New(rootCtx, conf.Web.MonitorHistory)
store := file.New(conf.Storage)
addrPolicy := &policy.Addressing{Config: conf.SMTP}
mmanager := &message.StoreManager{Store: store, Hub: msgHub}
// Start Retention scanner.