mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-05 22:17:39 +03:00
Add base Module interface and global registry
This commit is contained in:
parent
98d3caa827
commit
b3baf8ad25
2 changed files with 99 additions and 0 deletions
36
module/module.go
Normal file
36
module/module.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Package module contians interfaces implemented by maddy modules.
|
||||
//
|
||||
// They are moved to separate package to prevent circular dependencies.
|
||||
//
|
||||
// Each interface required by maddy for operation is provided by some object
|
||||
// called "module". This includes authentication, storage backends, DKIM,
|
||||
// email filters, etc. Each module may serve multiple functions. I.e. it can
|
||||
// be IMAP storage backend, SMTP upstream and authentication provider at the
|
||||
// same moment.
|
||||
//
|
||||
// Each module gets its own unique name (sqlmail for go-sqlmail, proxy for
|
||||
// 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
|
||||
// configuration.
|
||||
package module
|
||||
|
||||
import "github.com/mholt/caddy/caddyfile"
|
||||
|
||||
// Module is the interface implemented by all maddy module instances.
|
||||
//
|
||||
// It defines basic methods used to identify instances.
|
||||
type Module interface {
|
||||
// Name method reports module name.
|
||||
//
|
||||
// It is used to reference module in the configuration and in logs.
|
||||
Name() string
|
||||
|
||||
// InstanceName method reports unique name of this module instance.
|
||||
InstanceName() string
|
||||
|
||||
// Module version. Reported in logs.
|
||||
Version() string
|
||||
}
|
||||
|
||||
// NewModule is function that creates new instance of module with specified name.
|
||||
type NewModule func(name string, cfg map[string]caddyfile.Token) (Module, error)
|
Loading…
Add table
Add a link
Reference in a new issue