Prevent compose-system import cycles
This commit is contained in:
@@ -475,8 +475,9 @@ func (app *CortezaApp) InitServices(ctx context.Context) (err error) {
|
||||
// Note: this is a legacy approach, all services from all 3 apps
|
||||
// will most likely be merged in the future
|
||||
err = cmpService.Initialize(ctx, app.Log, app.Store, cmpService.Config{
|
||||
ActionLog: app.Opt.ActionLog,
|
||||
Storage: app.Opt.ObjStore,
|
||||
ActionLog: app.Opt.ActionLog,
|
||||
Storage: app.Opt.ObjStore,
|
||||
UserFinder: sysService.DefaultUser,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
@@ -507,6 +508,10 @@ func (app *CortezaApp) InitServices(ctx context.Context) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Register reporters
|
||||
// @todo additional datasource providers; generate?
|
||||
sysService.DefaultReport.RegisterReporter("composeRecords", cmpService.DefaultRecord)
|
||||
|
||||
// Initializing seeder
|
||||
_ = seeder.Seeder(ctx, app.Store, seeder.Faker())
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/cortezaproject/corteza-server/pkg/filter"
|
||||
"github.com/cortezaproject/corteza-server/pkg/payload"
|
||||
"github.com/cortezaproject/corteza-server/store"
|
||||
systemService "github.com/cortezaproject/corteza-server/system/service"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -50,7 +49,6 @@ type (
|
||||
namespace service.NamespaceService
|
||||
attachment service.AttachmentService
|
||||
ac recordAccessController
|
||||
userFinder systemService.UserService
|
||||
}
|
||||
|
||||
recordAccessController interface {
|
||||
@@ -70,9 +68,6 @@ func (Record) New() *Record {
|
||||
namespace: service.DefaultNamespace,
|
||||
attachment: service.DefaultAttachment,
|
||||
ac: service.DefaultAccessControl,
|
||||
|
||||
// See comment at DefaultSystemUser definition
|
||||
userFinder: systemService.DefaultUser,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/cortezaproject/corteza-server/pkg/actionlog"
|
||||
httpClient "github.com/cortezaproject/corteza-server/pkg/http"
|
||||
"github.com/cortezaproject/corteza-server/pkg/mail"
|
||||
systemService "github.com/cortezaproject/corteza-server/system/service"
|
||||
systemTypes "github.com/cortezaproject/corteza-server/system/types"
|
||||
)
|
||||
|
||||
@@ -28,7 +27,7 @@ type (
|
||||
// Warning: API endpoints on compose should be kept so that we do not break backward compatibility)
|
||||
notification struct {
|
||||
actionlog actionlog.Recorder
|
||||
users systemService.UserService
|
||||
users userFinder
|
||||
}
|
||||
|
||||
notificationUserFinder interface {
|
||||
@@ -36,10 +35,10 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func Notification() *notification {
|
||||
func Notification(uf userFinder) *notification {
|
||||
return ¬ification{
|
||||
actionlog: DefaultActionlog,
|
||||
users: systemService.DefaultUser,
|
||||
users: uf,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,19 @@ import (
|
||||
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
|
||||
"github.com/cortezaproject/corteza-server/pkg/options"
|
||||
"github.com/cortezaproject/corteza-server/store"
|
||||
systemService "github.com/cortezaproject/corteza-server/system/service"
|
||||
systemTypes "github.com/cortezaproject/corteza-server/system/types"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type (
|
||||
userFinder interface {
|
||||
FindByID(context.Context, uint64) (*systemTypes.User, error)
|
||||
}
|
||||
|
||||
Config struct {
|
||||
ActionLog options.ActionLogOpt
|
||||
Storage options.ObjectStoreOpt
|
||||
ActionLog options.ActionLogOpt
|
||||
Storage options.ObjectStoreOpt
|
||||
UserFinder userFinder
|
||||
}
|
||||
|
||||
eventDispatcher interface {
|
||||
@@ -148,7 +153,7 @@ func Initialize(_ context.Context, log *zap.Logger, s store.Storer, c Config) (e
|
||||
DefaultRecord = Record()
|
||||
DefaultPage = Page()
|
||||
DefaultChart = Chart()
|
||||
DefaultNotification = Notification()
|
||||
DefaultNotification = Notification(c.UserFinder)
|
||||
DefaultAttachment = Attachment(DefaultObjectStore)
|
||||
|
||||
RegisterIteratorProviders()
|
||||
@@ -184,10 +189,6 @@ func Initialize(_ context.Context, log *zap.Logger, s store.Storer, c Config) (e
|
||||
DefaultAttachment,
|
||||
)
|
||||
|
||||
// Register reporters
|
||||
// @todo additional datasource providers; generate?
|
||||
systemService.DefaultReport.RegisterReporter("composeRecords", DefaultRecord)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user