mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-07 06:57:37 +03:00
queue: Use inline arguments for storage location
This commit is contained in:
parent
b5747e6147
commit
6c6461dcb6
2 changed files with 20 additions and 11 deletions
|
@ -113,16 +113,22 @@ type QueueMetadata struct {
|
|||
}
|
||||
|
||||
func NewQueue(_, instName string, _, inlineArgs []string) (module.Module, error) {
|
||||
if len(inlineArgs) != 0 {
|
||||
return nil, errors.New("queue: inline arguments are not used")
|
||||
}
|
||||
return &Queue{
|
||||
q := &Queue{
|
||||
name: instName,
|
||||
initialRetryTime: 15 * time.Minute,
|
||||
retryTimeScale: 2,
|
||||
postInitDelay: 10 * time.Second,
|
||||
Log: log.Logger{Name: "queue"},
|
||||
}, nil
|
||||
}
|
||||
switch len(inlineArgs) {
|
||||
case 0:
|
||||
// Not inline definition.
|
||||
case 1:
|
||||
q.location = inlineArgs[0]
|
||||
default:
|
||||
return nil, errors.New("queue: wrong amount of inline arguments")
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (q *Queue) Init(cfg *config.Map) error {
|
||||
|
@ -130,7 +136,7 @@ func (q *Queue) Init(cfg *config.Map) error {
|
|||
cfg.Bool("debug", true, false, &q.Log.Debug)
|
||||
cfg.Int("max_tries", false, false, 8, &q.maxTries)
|
||||
cfg.Int("max_parallelism", false, false, 16, &maxParallelism)
|
||||
cfg.String("location", false, false, "", &q.location)
|
||||
cfg.String("location", false, false, q.location, &q.location)
|
||||
cfg.Custom("target", false, true, nil, modconfig.DeliveryDirective, &q.Target)
|
||||
cfg.String("hostname", true, true, "", &q.hostname)
|
||||
cfg.String("autogenerated_msg_domain", true, false, "", &q.autogenMsgDomain)
|
||||
|
@ -150,14 +156,11 @@ func (q *Queue) Init(cfg *config.Map) error {
|
|||
q.dsnDispatcher.Log = log.Logger{Name: "queue/dispatcher", Debug: q.Log.Debug}
|
||||
}
|
||||
if q.location == "" && q.name == "" {
|
||||
return errors.New("queue: need explicit location directive or config block name if defined inline")
|
||||
return errors.New("queue: need explicit location directive or inline argument if defined inline")
|
||||
}
|
||||
if q.location == "" {
|
||||
q.location = filepath.Join(config.StateDirectory, q.name)
|
||||
}
|
||||
if !filepath.IsAbs(q.location) {
|
||||
q.location = filepath.Join(config.StateDirectory, q.location)
|
||||
}
|
||||
|
||||
// TODO: Check location write permissions.
|
||||
if err := os.MkdirAll(q.location, os.ModePerm); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue