Rename go-sqlmail to go-imap-sql

Maddy module is named just 'sql' now.
This commit is contained in:
fox.cpp 2019-03-27 22:26:17 +03:00 committed by emersion
parent 6c22a22e79
commit addc2e8490
7 changed files with 30 additions and 30 deletions

View file

@ -213,7 +213,7 @@ smtp smtp://0.0.0.0:25 smtps://0.0.0.0:587 {
} }
``` ```
### 'sqlmail' module ### 'sql' module
SQL-based storage backend. Can be used as a storage backend (for IMAP), SQL-based storage backend. Can be used as a storage backend (for IMAP),
authentication provider (IMAP & SMTP) or delivery target (SMTP). authentication provider (IMAP & SMTP) or delivery target (SMTP).

View file

@ -12,12 +12,12 @@ go get github.com/emersion/maddy/cmd/maddy
Build tags: Build tags:
* `nosqlite3` * `nosqlite3`
Disable SQLite3 support in go-sqlmail (enabled by default). Saves around 9 Disable SQLite3 support in go-imap-sql (enabled by default). Saves around 9
MiB of binary size. MiB of binary size.
* `mysql` * `mysql`
Include support for MySQL driver in go-sqlmail. Include support for MySQL driver in go-imap-sql.
* `postgresql` * `postgresql`
Include support for PostgreSQL driver in go-sqlmail. Include support for PostgreSQL driver in go-imap-sql.
## Configuration ## Configuration
@ -88,16 +88,16 @@ Don't forget to use actual values instead of placeholders.
With this configuration, maddy will create an SQLite3 database for messages in With this configuration, maddy will create an SQLite3 database for messages in
current directory and use it to store all messages. current directory and use it to store all messages.
### go-sqlmail: Database location ### go-imap-sql: Database location
If you don't like SQLite3 or don't want to have it in the current directory, If you don't like SQLite3 or don't want to have it in the current directory,
you can override the configuration of the default module. you can override the configuration of the default module.
See [go-sqlmail repository](https://github.com/foxcpp/go-sqlmail) for See [go-imap-sql repository](https://github.com/foxcpp/go-imap-sql) for
information on RDBMS support. information on RDBMS support.
``` ```
sqlmail default { sql default {
driver sqlite3 driver sqlite3
dsn file_path dsn file_path
} }

View file

@ -29,12 +29,12 @@ func createDefaultStorage(_ string) (module.Module, error) {
return nil, fmt.Errorf("maddy is not compiled with %s support", defaultDriver) return nil, fmt.Errorf("maddy is not compiled with %s support", defaultDriver)
} }
return NewSQLMail("sqlmail", "default") return NewSQLStorage("sql", "default")
} }
func defaultStorageConfig(name string) config.Node { func defaultStorageConfig(name string) config.Node {
return config.Node{ return config.Node{
Name: "sqlmail", Name: "sql",
Args: []string{name}, Args: []string{name},
Children: []config.Node{ Children: []config.Node{
{ {

2
go.mod
View file

@ -9,7 +9,7 @@ require (
github.com/emersion/go-message v0.9.1 github.com/emersion/go-message v0.9.1
github.com/emersion/go-msgauth v0.0.0-20180104172905-3707cece5cdb github.com/emersion/go-msgauth v0.0.0-20180104172905-3707cece5cdb
github.com/emersion/go-smtp v0.10.0 github.com/emersion/go-smtp v0.10.0
github.com/foxcpp/go-sqlmail v0.0.0-20190319173524-e2a302b97a9f github.com/foxcpp/go-imap-sql v0.0.0-20190327190817-a134b89961e4
github.com/go-sql-driver/mysql v1.4.1 github.com/go-sql-driver/mysql v1.4.1
github.com/google/uuid v1.1.0 github.com/google/uuid v1.1.0
github.com/lib/pq v1.0.0 github.com/lib/pq v1.0.0

View file

@ -18,7 +18,7 @@ import (
appendlimit "github.com/emersion/go-imap-appendlimit" appendlimit "github.com/emersion/go-imap-appendlimit"
compress "github.com/emersion/go-imap-compress" compress "github.com/emersion/go-imap-compress"
move "github.com/emersion/go-imap-move" move "github.com/emersion/go-imap-move"
"github.com/foxcpp/go-sqlmail/imap/children" "github.com/foxcpp/go-imap-sql/imap/children"
) )
type IMAPEndpoint struct { type IMAPEndpoint struct {

View file

@ -8,7 +8,7 @@
// be IMAP storage backend, SMTP upstream and authentication provider at the // be IMAP storage backend, SMTP upstream and authentication provider at the
// same moment. // same moment.
// //
// Each module gets its own unique name (sqlmail for go-sqlmail, proxy for // Each module gets its own unique name (sql for go-imap-sql, proxy for
// proxy module, local for local delivery perhaps, etc). Each module instance // proxy module, local for local delivery perhaps, etc). Each module instance
// also gets its own (unique too) name which is used to refer to it in // also gets its own (unique too) name which is used to refer to it in
// configuration. // configuration.

View file

@ -12,12 +12,12 @@ import (
"github.com/emersion/maddy/config" "github.com/emersion/maddy/config"
"github.com/emersion/maddy/log" "github.com/emersion/maddy/log"
"github.com/emersion/maddy/module" "github.com/emersion/maddy/module"
"github.com/foxcpp/go-sqlmail" sqlstore "github.com/foxcpp/go-imap-sql"
imapsqlmail "github.com/foxcpp/go-sqlmail/imap" imapsql "github.com/foxcpp/go-imap-sql/imap"
) )
type SQLMail struct { type SQLStorage struct {
*imapsqlmail.Backend *imapsql.Backend
instName string instName string
Log log.Logger Log log.Logger
} }
@ -31,27 +31,27 @@ func (l Literal) Len() int {
return l.length return l.length
} }
func (sqlm *SQLMail) Name() string { func (sqlm *SQLStorage) Name() string {
return "sqlmail" return "sql"
} }
func (sqlm *SQLMail) InstanceName() string { func (sqlm *SQLStorage) InstanceName() string {
return sqlm.instName return sqlm.instName
} }
func NewSQLMail(_, instName string) (module.Module, error) { func NewSQLStorage(_, instName string) (module.Module, error) {
return &SQLMail{ return &SQLStorage{
instName: instName, instName: instName,
Log: log.Logger{Out: log.StderrLog, Name: "sqlmail"}, Log: log.Logger{Out: log.StderrLog, Name: "sql"},
}, nil }, nil
} }
func (sqlm *SQLMail) Init(globalCfg map[string]config.Node, rawCfg config.Node) error { func (sqlm *SQLStorage) Init(globalCfg map[string]config.Node, rawCfg config.Node) error {
var driver string var driver string
var dsn string var dsn string
appendlimitVal := int64(-1) appendlimitVal := int64(-1)
opts := imapsqlmail.Opts{} opts := imapsql.Opts{}
cfg := config.Map{} cfg := config.Map{}
cfg.String("driver", false, true, "", &driver) cfg.String("driver", false, true, "", &driver)
cfg.String("dsn", false, true, "", &dsn) cfg.String("dsn", false, true, "", &dsn)
@ -68,22 +68,22 @@ func (sqlm *SQLMail) Init(globalCfg map[string]config.Node, rawCfg config.Node)
opts.MaxMsgBytes = new(uint32) opts.MaxMsgBytes = new(uint32)
*opts.MaxMsgBytes = uint32(appendlimitVal) *opts.MaxMsgBytes = uint32(appendlimitVal)
} }
back, err := imapsqlmail.NewBackend(driver, dsn, opts) back, err := imapsql.NewBackend(driver, dsn, opts)
if err != nil { if err != nil {
return fmt.Errorf("sqlmail: %s", err) return fmt.Errorf("sql: %s", err)
} }
sqlm.Backend = back sqlm.Backend = back
sqlm.Log.Debugln("go-sqlmail version", sqlmail.VersionStr) sqlm.Log.Debugln("go-imap-sql version", sqlstore.VersionStr)
return nil return nil
} }
func (sqlm *SQLMail) IMAPExtensions() []string { func (sqlm *SQLStorage) IMAPExtensions() []string {
return []string{"APPENDLIMIT", "MOVE", "CHILDREN"} return []string{"APPENDLIMIT", "MOVE", "CHILDREN"}
} }
func (sqlm *SQLMail) Deliver(ctx module.DeliveryContext, msg io.Reader) error { func (sqlm *SQLStorage) Deliver(ctx module.DeliveryContext, msg io.Reader) error {
var buf bytes.Buffer var buf bytes.Buffer
if _, err := io.Copy(&buf, msg); err != nil { if _, err := io.Copy(&buf, msg); err != nil {
return err return err
@ -162,5 +162,5 @@ func (sqlm *SQLMail) Deliver(ctx module.DeliveryContext, msg io.Reader) error {
} }
func init() { func init() {
module.Register("sqlmail", NewSQLMail) module.Register("sql", NewSQLStorage)
} }