3
0

upd(crm): Init doesn't need sync.Once

This commit is contained in:
Tit Petric
2019-04-03 14:06:35 +02:00
parent 54403fca4a
commit 2b2c0f95eb
2 changed files with 16 additions and 20 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ func (s *notification) expandUserRefs(recipients []string) ([]string, error) {
// First, get userID off the table
if userID, _ := strconv.ParseUint(rcpt, 10, 64); userID > 0 {
if user, err := s.userSvc.FindByID(userID); err != nil {
return nil, errors.Wrapf(err, "invalid recipient %v", userID)
return nil, errors.Wrapf(err, "invalid recipient %d", userID)
} else {
recipients[r] = user.Email + " " + user.Name
}
+15 -19
View File
@@ -1,9 +1,6 @@
package service
import (
"log"
"sync"
"github.com/crusttech/crust/internal/store"
)
@@ -14,7 +11,6 @@ type (
)
var (
o sync.Once
DefaultRecord RecordService
DefaultModule ModuleService
DefaultTrigger TriggerService
@@ -25,20 +21,20 @@ var (
DefaultAttachment AttachmentService
)
func Init() {
o.Do(func() {
fs, err := store.New("var/store")
if err != nil {
log.Fatalf("Failed to initialize store: %v", err)
}
func Init() error {
fs, err := store.New("var/store")
if err != nil {
return err
}
DefaultPermissions = Permissions()
DefaultRecord = Record()
DefaultModule = Module()
DefaultTrigger = Trigger()
DefaultPage = Page()
DefaultChart = Chart()
DefaultNotification = Notification()
DefaultAttachment = Attachment(fs)
})
DefaultPermissions = Permissions()
DefaultRecord = Record()
DefaultModule = Module()
DefaultTrigger = Trigger()
DefaultPage = Page()
DefaultChart = Chart()
DefaultNotification = Notification()
DefaultAttachment = Attachment(fs)
return nil
}