func (w *workerMsg) reset(e *mail.Envelope, task SelectTask) {
	if w.notifyMe == nil {
		w.notifyMe = make(chan *notifyMsg)
	}
	w.e = e
	w.task = task
}
reset resets a workerMsg that has been borrowed from the pool
package backends
import (
	"errors"
	"fmt"
	"strconv"
	"sync"
	"time"
	"runtime/debug"
	"strings"
	"github.com/flashmob/go-guerrilla/log"
	"github.com/flashmob/go-guerrilla/mail"
	"github.com/flashmob/go-guerrilla/response"
)
var ErrProcessorNotFound error
type BackendGateway struct {
	conveyor chan *workerMsg
	wg           sync.WaitGroup
	workStoppers []chan bool
	processors   []Processor
	validators   []Processor
	sync.Mutex
	State    backendState
	config   BackendConfig
	gwConfig *GatewayConfig
}
type GatewayConfig struct {
	WorkersSize int `json:"save_workers_size,omitempty"`
	SaveProcess string `json:"save_process,omitempty"`
	ValidateProcess string `json:"validate_process,omitempty"`
	TimeoutSave string `json:"gw_save_timeout,omitempty"`
	TimeoutValidateRcpt string `json:"gw_val_rcpt_timeout,omitempty"`
}
type workerMsg struct {
	e *mail.Envelope
	notifyMe chan *notifyMsg
	task SelectTask
}
type backendState int
const (
	BackendStateNew backendState = iota
	BackendStateRunning
	BackendStateShuttered
	BackendStateError
	BackendStateInitialized
	saveTimeout = time.Second * 30
	validateRcptTimeout = time.Second * 5
	defaultProcessor    = "Debugger"
)
func (s backendState) String() string {
	switch s {
	case BackendStateNew:
		return "NewState"
	case BackendStateRunning:
		return "RunningState"
	case BackendStateShuttered:
		return "ShutteredState"
	case BackendStateError:
		return "ErrorSate"
	case BackendStateInitialized:
		return "InitializedState"
	}
	return strconv.Itoa(int(s))
}
func New(backendConfig BackendConfig, l log.Logger) (Backend, error) {
	Svc.SetMainlog(l)
	gateway := &BackendGateway{}
	err := gateway.Initialize(backendConfig)
	if err != nil {
		return nil, fmt.Errorf("error while initializing the backend: %s", err)
	}
	gateway.config = backendConfig
	b = Backend(gateway)
	return b, nil
}
var workerMsgPool = sync.Pool{
	New: func() interface{} {
		return &workerMsg{}
	},
}