mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-07 21:37:04 +09:00
GO-2548 Move folders
This commit is contained in:
parent
bf7401e642
commit
d9bc94140f
37 changed files with 183 additions and 1934 deletions
|
@ -18,7 +18,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
|
||||
coresb "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/threads"
|
||||
"github.com/anyproto/anytype-heart/space/objectprovider"
|
||||
"github.com/anyproto/anytype-heart/space/internal/objectprovider"
|
||||
)
|
||||
|
||||
type Space interface {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/core/block/object/objectcache"
|
||||
"github.com/anyproto/anytype-heart/core/domain"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
|
||||
"github.com/anyproto/anytype-heart/space/techspace"
|
||||
"github.com/anyproto/anytype-heart/space/internal/techspace"
|
||||
)
|
||||
|
||||
type TechSpace struct {
|
||||
|
|
|
@ -3,9 +3,30 @@ package space
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/process/loader"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/localstore/addr"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/loader"
|
||||
)
|
||||
|
||||
func (s *service) initMarketplaceSpace(ctx context.Context) error {
|
||||
ctrl, err := s.factory.CreateMarketplaceSpace(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ctrl.Start(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.spaceControllers[addr.AnytypeMarketplaceWorkspace] = ctrl
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) initTechSpace() (err error) {
|
||||
s.techSpace, err = s.factory.CreateAndSetTechSpace(s.ctx)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *service) initPersonalSpace() (err error) {
|
||||
if s.newAccount {
|
||||
return s.createPersonalSpace(s.ctx)
|
|
@ -8,14 +8,14 @@ import (
|
|||
|
||||
"github.com/anyproto/anytype-heart/core/block/object/objectcache"
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/space/components/dependencies"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacestatus"
|
||||
dependencies2 "github.com/anyproto/anytype-heart/space/internal/components/dependencies"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/techspace"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore/storage"
|
||||
"github.com/anyproto/anytype-heart/space/techspace"
|
||||
)
|
||||
|
||||
const CName = "client.common.builder"
|
||||
const CName = "client.components.builder"
|
||||
|
||||
type SpaceBuilder interface {
|
||||
app.Component
|
||||
|
@ -27,8 +27,8 @@ func New() SpaceBuilder {
|
|||
}
|
||||
|
||||
type spaceBuilder struct {
|
||||
indexer dependencies.SpaceIndexer
|
||||
installer dependencies.BundledObjectsInstaller
|
||||
indexer dependencies2.SpaceIndexer
|
||||
installer dependencies2.BundledObjectsInstaller
|
||||
spaceCore spacecore.SpaceCoreService
|
||||
techSpace techspace.TechSpace
|
||||
accountService accountservice.Service
|
||||
|
@ -43,8 +43,9 @@ type spaceBuilder struct {
|
|||
|
||||
func (b *spaceBuilder) Init(a *app.App) (err error) {
|
||||
b.ctx, b.cancel = context.WithCancel(context.Background())
|
||||
b.indexer = app.MustComponent[dependencies.SpaceIndexer](a)
|
||||
b.installer = app.MustComponent[dependencies.BundledObjectsInstaller](a)
|
||||
b.status = app.MustComponent[spacestatus.SpaceStatus](a)
|
||||
b.indexer = app.MustComponent[dependencies2.SpaceIndexer](a)
|
||||
b.installer = app.MustComponent[dependencies2.BundledObjectsInstaller](a)
|
||||
b.spaceCore = app.MustComponent[spacecore.SpaceCoreService](a)
|
||||
b.techSpace = app.MustComponent[techspace.TechSpace](a)
|
||||
b.accountService = app.MustComponent[accountservice.Service](a)
|
|
@ -8,14 +8,14 @@ import (
|
|||
"github.com/anyproto/any-sync/app"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/space/components/builder"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/builder"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/techspace"
|
||||
spaceservice "github.com/anyproto/anytype-heart/space/spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
"github.com/anyproto/anytype-heart/space/techspace"
|
||||
)
|
||||
|
||||
const CName = "common.clientspace.spaceloader"
|
||||
const CName = "client.components.spaceloader"
|
||||
|
||||
var (
|
||||
ErrSpaceDeleted = errors.New("space is deleted")
|
||||
|
@ -38,8 +38,6 @@ type spaceLoader struct {
|
|||
space clientspace.Space
|
||||
|
||||
justCreated bool
|
||||
loadCh chan struct{}
|
||||
loadErr error
|
||||
}
|
||||
|
||||
func New(justCreated bool) SpaceLoader {
|
||||
|
@ -50,8 +48,9 @@ func New(justCreated bool) SpaceLoader {
|
|||
|
||||
func (s *spaceLoader) Init(a *app.App) (err error) {
|
||||
s.ctx, s.cancel = context.WithCancel(context.Background())
|
||||
s.techSpace = a.MustComponent(techspace.CName).(techspace.TechSpace)
|
||||
s.loadCh = make(chan struct{})
|
||||
s.techSpace = app.MustComponent[techspace.TechSpace](a)
|
||||
s.status = app.MustComponent[spacestatus.SpaceStatus](a)
|
||||
s.builder = app.MustComponent[builder.SpaceBuilder](a)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -129,6 +128,8 @@ func (s *spaceLoader) onLoad(spaceID string, sp clientspace.Space, loadErr error
|
|||
})
|
||||
}
|
||||
|
||||
s.space = sp
|
||||
s.loading = nil
|
||||
// TODO: check remote state
|
||||
return s.status.SetLocalInfo(s.ctx, spaceinfo.SpaceLocalInfo{
|
||||
SpaceID: spaceID,
|
||||
|
@ -151,7 +152,7 @@ func (s *spaceLoader) WaitLoad(ctx context.Context) (sp clientspace.Space, err e
|
|||
return nil, fmt.Errorf("waitLoad for an unknown space")
|
||||
case spaceinfo.LocalStatusLoading:
|
||||
// loading in progress, wait channel and retry
|
||||
waitCh := s.loadCh
|
||||
waitCh := s.loading.loadCh
|
||||
s.status.Unlock()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
@ -161,7 +162,7 @@ func (s *spaceLoader) WaitLoad(ctx context.Context) (sp clientspace.Space, err e
|
|||
return s.WaitLoad(ctx)
|
||||
case spaceinfo.LocalStatusMissing:
|
||||
// local missing state means the loader ended with an error
|
||||
err = s.loadErr
|
||||
err = s.loading.loadErr
|
||||
case spaceinfo.LocalStatusOk:
|
||||
sp = s.space
|
||||
default:
|
|
@ -9,15 +9,15 @@ import (
|
|||
"github.com/anyproto/any-sync/app/logger"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/components/dependencies"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
dependencies2 "github.com/anyproto/anytype-heart/space/internal/components/dependencies"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore/storage"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
)
|
||||
|
||||
const CName = "client.common.spaceoffloader"
|
||||
const CName = "client.components.spaceoffloader"
|
||||
|
||||
var log = logger.NewNamed(CName)
|
||||
|
||||
|
@ -35,9 +35,9 @@ func New() SpaceOffloader {
|
|||
type spaceOffloader struct {
|
||||
status spacestatus.SpaceStatus
|
||||
offloading *offloadingSpace
|
||||
fileOffloader dependencies.FileOffloader
|
||||
fileOffloader dependencies2.FileOffloader
|
||||
storageService storage.ClientStorage
|
||||
indexer dependencies.SpaceIndexer
|
||||
indexer dependencies2.SpaceIndexer
|
||||
spaceCore spacecore.SpaceCoreService
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
@ -46,9 +46,9 @@ type spaceOffloader struct {
|
|||
|
||||
func (o *spaceOffloader) Init(a *app.App) (err error) {
|
||||
o.status = app.MustComponent[spacestatus.SpaceStatus](a)
|
||||
o.fileOffloader = app.MustComponent[dependencies.FileOffloader](a)
|
||||
o.fileOffloader = app.MustComponent[dependencies2.FileOffloader](a)
|
||||
o.storageService = app.MustComponent[storage.ClientStorage](a)
|
||||
o.indexer = app.MustComponent[dependencies.SpaceIndexer](a)
|
||||
o.indexer = app.MustComponent[dependencies2.SpaceIndexer](a)
|
||||
o.spaceCore = app.MustComponent[spacecore.SpaceCoreService](a)
|
||||
o.ctx, o.cancel = context.WithCancel(context.Background())
|
||||
return nil
|
||||
|
@ -79,6 +79,7 @@ func (o *spaceOffloader) Run(ctx context.Context) (err error) {
|
|||
}
|
||||
}
|
||||
if localStatus == spaceinfo.LocalStatusMissing {
|
||||
o.offloaded.Store(true)
|
||||
return nil
|
||||
}
|
||||
o.offloading = newOffloadingSpace(o.ctx, o.status.SpaceId(), o)
|
||||
|
@ -87,21 +88,19 @@ func (o *spaceOffloader) Run(ctx context.Context) (err error) {
|
|||
|
||||
func (o *spaceOffloader) Close(ctx context.Context) (err error) {
|
||||
o.cancel()
|
||||
if o.offloading != nil {
|
||||
<-o.offloading.loadCh
|
||||
o.status.Lock()
|
||||
ol := o.offloading
|
||||
o.status.Unlock()
|
||||
if ol != nil {
|
||||
<-ol.loadCh
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *spaceOffloader) CanTransition(next modechanger.Mode) bool {
|
||||
func (o *spaceOffloader) CanTransition(next mode.Mode) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (o *spaceOffloader) startOffload(ctx context.Context, id string) (err error) {
|
||||
o.offloading = newOffloadingSpace(ctx, id, o)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *spaceOffloader) onOffload(id string, offloadErr error) {
|
||||
if offloadErr != nil {
|
||||
log.Warn("offload error", zap.Error(offloadErr), zap.String("spaceId", id))
|
||||
|
@ -113,6 +112,7 @@ func (o *spaceOffloader) onOffload(id string, offloadErr error) {
|
|||
log.Debug("set status error", zap.Error(err), zap.String("spaceId", id))
|
||||
}
|
||||
o.offloaded.Store(true)
|
||||
o.offloading = nil
|
||||
}
|
||||
|
||||
func (o *spaceOffloader) WaitOffload(ctx context.Context) (err error) {
|
|
@ -6,11 +6,11 @@ import (
|
|||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/internal/techspace"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
"github.com/anyproto/anytype-heart/space/techspace"
|
||||
)
|
||||
|
||||
const CName = "client.common.spacestatus"
|
||||
const CName = "client.components.spacestatus"
|
||||
|
||||
type SpaceStatus interface {
|
||||
app.Component
|
|
@ -10,9 +10,9 @@ import (
|
|||
"github.com/anyproto/anytype-heart/core/block/object/objectcache"
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/localstore/addr"
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/space/components/dependencies"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
dependencies "github.com/anyproto/anytype-heart/space/internal/components/dependencies"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
"github.com/anyproto/anytype-heart/space/virtualspaceservice"
|
||||
)
|
||||
|
@ -59,8 +59,8 @@ func (s *spaceController) Start(ctx context.Context) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
func (s *spaceController) Mode() modechanger.Mode {
|
||||
return modechanger.ModeLoading
|
||||
func (s *spaceController) Mode() mode.Mode {
|
||||
return mode.ModeLoading
|
||||
}
|
||||
|
||||
func (s *spaceController) WaitLoad(ctx context.Context) (sp clientspace.Space, err error) {
|
|
@ -6,14 +6,14 @@ import (
|
|||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/components/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/components/spaceloader"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/process/loader"
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spaceloader"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/loader"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
"github.com/anyproto/anytype-heart/space/internal/techspace"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
"github.com/anyproto/anytype-heart/space/techspace"
|
||||
)
|
||||
|
||||
func NewSpaceController(
|
||||
|
@ -77,8 +77,8 @@ func (s *spaceController) Start(ctx context.Context) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
func (s *spaceController) Mode() modechanger.Mode {
|
||||
return modechanger.ModeLoading
|
||||
func (s *spaceController) Mode() mode.Mode {
|
||||
return mode.ModeLoading
|
||||
}
|
||||
|
||||
func (s *spaceController) Current() any {
|
|
@ -5,13 +5,14 @@ import (
|
|||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/components/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/process/initial"
|
||||
"github.com/anyproto/anytype-heart/space/process/loader"
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
"github.com/anyproto/anytype-heart/space/process/offloader"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/initial"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/loader"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/offloader"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
)
|
||||
|
||||
|
@ -24,7 +25,7 @@ type spaceController struct {
|
|||
status spacestatus.SpaceStatus
|
||||
lastUpdatedStatus spaceinfo.AccountStatus
|
||||
|
||||
sm *modechanger.StateMachine
|
||||
sm *mode.StateMachine
|
||||
}
|
||||
|
||||
func NewSpaceController(
|
||||
|
@ -39,7 +40,7 @@ func NewSpaceController(
|
|||
lastUpdatedStatus: status,
|
||||
app: a,
|
||||
}
|
||||
sm, err := modechanger.NewStateMachine(s, log)
|
||||
sm, err := mode.NewStateMachine(s, log.With(zap.String("spaceId", spaceId)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -54,18 +55,18 @@ func (s *spaceController) SpaceId() string {
|
|||
func (s *spaceController) Start(ctx context.Context) error {
|
||||
switch s.status.GetPersistentStatus() {
|
||||
case spaceinfo.AccountStatusDeleted:
|
||||
_, err := s.sm.ChangeMode(modechanger.ModeOffloading)
|
||||
_, err := s.sm.ChangeMode(mode.ModeOffloading)
|
||||
return err
|
||||
case spaceinfo.AccountStatusInviting:
|
||||
_, err := s.sm.ChangeMode(modechanger.ModeInviting)
|
||||
_, err := s.sm.ChangeMode(mode.ModeInviting)
|
||||
return err
|
||||
default:
|
||||
_, err := s.sm.ChangeMode(modechanger.ModeLoading)
|
||||
_, err := s.sm.ChangeMode(mode.ModeLoading)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s *spaceController) Mode() modechanger.Mode {
|
||||
func (s *spaceController) Mode() mode.Mode {
|
||||
return s.sm.GetMode()
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ func (s *spaceController) UpdateStatus(ctx context.Context, status spaceinfo.Acc
|
|||
}
|
||||
s.lastUpdatedStatus = status
|
||||
s.status.Unlock()
|
||||
updateStatus := func(mode modechanger.Mode) error {
|
||||
updateStatus := func(mode mode.Mode) error {
|
||||
s.status.Lock()
|
||||
s.status.UpdatePersistentStatus(ctx, status)
|
||||
s.status.Unlock()
|
||||
|
@ -90,11 +91,11 @@ func (s *spaceController) UpdateStatus(ctx context.Context, status spaceinfo.Acc
|
|||
}
|
||||
switch status {
|
||||
case spaceinfo.AccountStatusDeleted:
|
||||
return updateStatus(modechanger.ModeOffloading)
|
||||
return updateStatus(mode.ModeOffloading)
|
||||
case spaceinfo.AccountStatusInviting:
|
||||
return updateStatus(modechanger.ModeInviting)
|
||||
return updateStatus(mode.ModeInviting)
|
||||
default:
|
||||
return updateStatus(modechanger.ModeLoading)
|
||||
return updateStatus(mode.ModeLoading)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,7 @@ func (s *spaceController) UpdateRemoteStatus(ctx context.Context, status spacein
|
|||
}
|
||||
|
||||
func (s *spaceController) Delete(ctx context.Context) error {
|
||||
offloading, err := s.sm.ChangeMode(modechanger.ModeOffloading)
|
||||
offloading, err := s.sm.ChangeMode(mode.ModeOffloading)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -113,26 +114,17 @@ func (s *spaceController) Delete(ctx context.Context) error {
|
|||
return of.WaitOffload(ctx)
|
||||
}
|
||||
|
||||
func (s *spaceController) Invite(ctx context.Context) error {
|
||||
offloading, err := s.sm.ChangeMode(modechanger.ModeOffloading)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
of := offloading.(offloader.Offloader)
|
||||
return of.WaitOffload(ctx)
|
||||
}
|
||||
|
||||
func (s *spaceController) Process(mode modechanger.Mode) modechanger.Process {
|
||||
switch mode {
|
||||
case modechanger.ModeInitial:
|
||||
func (s *spaceController) Process(md mode.Mode) mode.Process {
|
||||
switch md {
|
||||
case mode.ModeInitial:
|
||||
return initial.New()
|
||||
case modechanger.ModeLoading:
|
||||
case mode.ModeLoading:
|
||||
return loader.New(s.app, loader.Params{
|
||||
JustCreated: s.justCreated,
|
||||
SpaceId: s.spaceId,
|
||||
Status: s.status,
|
||||
})
|
||||
case modechanger.ModeOffloading:
|
||||
case mode.ModeOffloading:
|
||||
return offloader.New(s.app, offloader.Params{
|
||||
Status: s.status,
|
||||
})
|
|
@ -10,18 +10,18 @@ import (
|
|||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/process/initial"
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/initial"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
)
|
||||
|
||||
type modeRegister struct {
|
||||
modes []modechanger.Mode
|
||||
modes []mode.Mode
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func (m *modeRegister) register(mode modechanger.Mode) {
|
||||
func (m *modeRegister) register(mode mode.Mode) {
|
||||
m.Lock()
|
||||
m.modes = append(m.modes, mode)
|
||||
m.Unlock()
|
||||
|
@ -102,7 +102,7 @@ type inviting struct {
|
|||
reg *modeRegister
|
||||
}
|
||||
|
||||
func newInviting(status spacestatus.SpaceStatus, reg *modeRegister) modechanger.Process {
|
||||
func newInviting(status spacestatus.SpaceStatus, reg *modeRegister) mode.Process {
|
||||
return &inviting{
|
||||
status: status,
|
||||
reg: reg,
|
||||
|
@ -116,7 +116,7 @@ func (i *inviting) Start(ctx context.Context) error {
|
|||
i.status.SetPersistentStatus(ctx, spaceinfo.AccountStatusLoading)
|
||||
i.status.Unlock()
|
||||
}()
|
||||
i.reg.register(modechanger.ModeInviting)
|
||||
i.reg.register(mode.ModeInviting)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,8 @@ func (i *inviting) Close(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (i *inviting) CanTransition(next modechanger.Mode) bool {
|
||||
if next == modechanger.ModeLoading && !i.inviteReceived.Load() {
|
||||
func (i *inviting) CanTransition(next mode.Mode) bool {
|
||||
if next == mode.ModeLoading && !i.inviteReceived.Load() {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -136,7 +136,7 @@ type loading struct {
|
|||
reg *modeRegister
|
||||
}
|
||||
|
||||
func newLoading(status spacestatus.SpaceStatus, reg *modeRegister) modechanger.Process {
|
||||
func newLoading(status spacestatus.SpaceStatus, reg *modeRegister) mode.Process {
|
||||
return &loading{
|
||||
status: status,
|
||||
reg: reg,
|
||||
|
@ -144,7 +144,7 @@ func newLoading(status spacestatus.SpaceStatus, reg *modeRegister) modechanger.P
|
|||
}
|
||||
|
||||
func (l *loading) Start(ctx context.Context) error {
|
||||
l.reg.register(modechanger.ModeLoading)
|
||||
l.reg.register(mode.ModeLoading)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ func (l *loading) Close(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (l *loading) CanTransition(next modechanger.Mode) bool {
|
||||
func (l *loading) CanTransition(next mode.Mode) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ type offloading struct {
|
|||
reg *modeRegister
|
||||
}
|
||||
|
||||
func newOffloading(status spacestatus.SpaceStatus, reg *modeRegister) modechanger.Process {
|
||||
func newOffloading(status spacestatus.SpaceStatus, reg *modeRegister) mode.Process {
|
||||
return &offloading{
|
||||
status: status,
|
||||
reg: reg,
|
||||
|
@ -169,7 +169,7 @@ func newOffloading(status spacestatus.SpaceStatus, reg *modeRegister) modechange
|
|||
}
|
||||
|
||||
func (l *offloading) Start(ctx context.Context) error {
|
||||
l.reg.register(modechanger.ModeOffloading)
|
||||
l.reg.register(mode.ModeOffloading)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ func (l *offloading) Close(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (l *offloading) CanTransition(next modechanger.Mode) bool {
|
||||
func (l *offloading) CanTransition(next mode.Mode) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -186,15 +186,15 @@ type factory struct {
|
|||
reg *modeRegister
|
||||
}
|
||||
|
||||
func (f factory) Process(mode modechanger.Mode) modechanger.Process {
|
||||
switch mode {
|
||||
case modechanger.ModeInitial:
|
||||
func (f factory) Process(md mode.Mode) mode.Process {
|
||||
switch md {
|
||||
case mode.ModeInitial:
|
||||
return initial.New()
|
||||
case modechanger.ModeInviting:
|
||||
case mode.ModeInviting:
|
||||
return newInviting(f.status, f.reg)
|
||||
case modechanger.ModeLoading:
|
||||
case mode.ModeLoading:
|
||||
return newLoading(f.status, f.reg)
|
||||
case modechanger.ModeOffloading:
|
||||
case mode.ModeOffloading:
|
||||
return newOffloading(f.status, f.reg)
|
||||
default:
|
||||
panic("unhandled default case")
|
||||
|
@ -219,7 +219,7 @@ func newFixture(t *testing.T, startStatus spaceinfo.AccountStatus) *fixture {
|
|||
status: s,
|
||||
reg: reg,
|
||||
}
|
||||
sm, err := modechanger.NewStateMachine(f, log)
|
||||
sm, err := mode.NewStateMachine(f, log)
|
||||
require.NoError(t, err)
|
||||
controller := &spaceController{
|
||||
spaceId: "spaceId",
|
||||
|
@ -254,11 +254,11 @@ func TestSpaceController_InvitingLoading(t *testing.T) {
|
|||
defer fx.stop()
|
||||
err := fx.ctrl.Start(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, modechanger.ModeInviting, fx.ctrl.Mode())
|
||||
require.Equal(t, mode.ModeInviting, fx.ctrl.Mode())
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
fx.reg.Lock()
|
||||
defer fx.reg.Unlock()
|
||||
require.Equal(t, []modechanger.Mode{modechanger.ModeInviting, modechanger.ModeLoading}, fx.reg.modes)
|
||||
require.Equal(t, []mode.Mode{mode.ModeInviting, mode.ModeLoading}, fx.reg.modes)
|
||||
}
|
||||
|
||||
func TestSpaceController_LoadingDeleting(t *testing.T) {
|
||||
|
@ -266,12 +266,12 @@ func TestSpaceController_LoadingDeleting(t *testing.T) {
|
|||
defer fx.stop()
|
||||
err := fx.ctrl.Start(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, modechanger.ModeLoading, fx.ctrl.Mode())
|
||||
require.Equal(t, mode.ModeLoading, fx.ctrl.Mode())
|
||||
err = fx.ctrl.UpdateStatus(context.Background(), spaceinfo.AccountStatusDeleted)
|
||||
require.NoError(t, err)
|
||||
fx.reg.Lock()
|
||||
defer fx.reg.Unlock()
|
||||
require.Equal(t, []modechanger.Mode{modechanger.ModeLoading, modechanger.ModeOffloading}, fx.reg.modes)
|
||||
require.Equal(t, []mode.Mode{mode.ModeLoading, mode.ModeOffloading}, fx.reg.modes)
|
||||
}
|
||||
|
||||
func TestSpaceController_LoadingDeletingMultipleWaiters(t *testing.T) {
|
||||
|
@ -279,7 +279,7 @@ func TestSpaceController_LoadingDeletingMultipleWaiters(t *testing.T) {
|
|||
defer fx.stop()
|
||||
err := fx.ctrl.Start(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, modechanger.ModeLoading, fx.ctrl.Mode())
|
||||
require.Equal(t, mode.ModeLoading, fx.ctrl.Mode())
|
||||
wg := sync.WaitGroup{}
|
||||
for i := 0; i < 10; i++ {
|
||||
wg.Add(1)
|
||||
|
@ -292,7 +292,7 @@ func TestSpaceController_LoadingDeletingMultipleWaiters(t *testing.T) {
|
|||
wg.Wait()
|
||||
fx.reg.Lock()
|
||||
defer fx.reg.Unlock()
|
||||
require.Equal(t, []modechanger.Mode{modechanger.ModeLoading, modechanger.ModeOffloading}, fx.reg.modes)
|
||||
require.Equal(t, []mode.Mode{mode.ModeLoading, mode.ModeOffloading}, fx.reg.modes)
|
||||
}
|
||||
|
||||
func TestSpaceController_Deleting(t *testing.T) {
|
||||
|
@ -300,11 +300,11 @@ func TestSpaceController_Deleting(t *testing.T) {
|
|||
defer fx.stop()
|
||||
err := fx.ctrl.Start(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, modechanger.ModeOffloading, fx.ctrl.Mode())
|
||||
require.Equal(t, mode.ModeOffloading, fx.ctrl.Mode())
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
fx.reg.Lock()
|
||||
defer fx.reg.Unlock()
|
||||
require.Equal(t, []modechanger.Mode{modechanger.ModeOffloading}, fx.reg.modes)
|
||||
require.Equal(t, []mode.Mode{mode.ModeOffloading}, fx.reg.modes)
|
||||
}
|
||||
|
||||
func TestSpaceController_DeletingInvalid(t *testing.T) {
|
||||
|
@ -312,10 +312,10 @@ func TestSpaceController_DeletingInvalid(t *testing.T) {
|
|||
defer fx.stop()
|
||||
err := fx.ctrl.Start(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, modechanger.ModeOffloading, fx.ctrl.Mode())
|
||||
require.Equal(t, mode.ModeOffloading, fx.ctrl.Mode())
|
||||
err = fx.ctrl.UpdateStatus(context.Background(), spaceinfo.AccountStatusLoading)
|
||||
require.Error(t, err)
|
||||
fx.reg.Lock()
|
||||
defer fx.reg.Unlock()
|
||||
require.Equal(t, []modechanger.Mode{modechanger.ModeOffloading}, fx.reg.modes)
|
||||
require.Equal(t, []mode.Mode{mode.ModeOffloading}, fx.reg.modes)
|
||||
}
|
|
@ -3,14 +3,14 @@ package spacecontroller
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
)
|
||||
|
||||
type SpaceController interface {
|
||||
SpaceId() string
|
||||
Start(ctx context.Context) error
|
||||
Mode() modechanger.Mode
|
||||
Mode() mode.Mode
|
||||
Current() any
|
||||
UpdateStatus(ctx context.Context, status spaceinfo.AccountStatus) error
|
||||
UpdateRemoteStatus(ctx context.Context, status spaceinfo.RemoteStatus) error
|
|
@ -12,14 +12,14 @@ import (
|
|||
|
||||
"github.com/anyproto/anytype-heart/core/block/object/objectcache"
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/space/components/dependencies"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/marketplacespace"
|
||||
"github.com/anyproto/anytype-heart/space/personalspace"
|
||||
"github.com/anyproto/anytype-heart/space/shareablespace"
|
||||
dependencies "github.com/anyproto/anytype-heart/space/internal/components/dependencies"
|
||||
"github.com/anyproto/anytype-heart/space/internal/marketplacespace"
|
||||
"github.com/anyproto/anytype-heart/space/internal/personalspace"
|
||||
"github.com/anyproto/anytype-heart/space/internal/shareablespace"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/internal/techspace"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
"github.com/anyproto/anytype-heart/space/techspace"
|
||||
)
|
||||
|
||||
type SpaceFactory interface {
|
||||
|
@ -50,6 +50,25 @@ func New() SpaceFactory {
|
|||
return &spaceFactory{}
|
||||
}
|
||||
|
||||
func (s *spaceFactory) Init(a *app.App) (err error) {
|
||||
s.app = a
|
||||
s.spaceCore = app.MustComponent[spacecore.SpaceCoreService](a)
|
||||
s.accountService = app.MustComponent[accountservice.Service](a)
|
||||
s.objectFactory = app.MustComponent[objectcache.ObjectFactory](a)
|
||||
s.indexer = app.MustComponent[dependencies.SpaceIndexer](a)
|
||||
s.installer = app.MustComponent[dependencies.BundledObjectsInstaller](a)
|
||||
s.personalSpaceId, err = s.spaceCore.DeriveID(context.Background(), spacecore.SpaceType)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
s.metadataPayload, err = deriveAccountMetadata(s.accountService.Account().SignKey)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
s.repKey, err = getRepKey(s.personalSpaceId)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *spaceFactory) CreatePersonalSpace(ctx context.Context) (sp spacecontroller.SpaceController, err error) {
|
||||
coreSpace, err := s.spaceCore.Derive(ctx, spacecore.SpaceType)
|
||||
if err != nil {
|
||||
|
@ -134,22 +153,6 @@ func (s *spaceFactory) CreateMarketplaceSpace(ctx context.Context) (sp spacecont
|
|||
return ctrl, err
|
||||
}
|
||||
|
||||
func (s *spaceFactory) Init(a *app.App) (err error) {
|
||||
s.app = a
|
||||
s.techSpace = a.MustComponent(techspace.CName).(techspace.TechSpace)
|
||||
s.spaceCore = a.MustComponent(spacecore.CName).(spacecore.SpaceCoreService)
|
||||
s.personalSpaceId, err = s.spaceCore.DeriveID(context.Background(), spacecore.SpaceType)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
s.metadataPayload, err = deriveAccountMetadata(s.accountService.Account().SignKey)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
s.repKey, err = getRepKey(s.personalSpaceId)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *spaceFactory) Name() (name string) {
|
||||
return CName
|
||||
}
|
|
@ -3,13 +3,13 @@ package initial
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
)
|
||||
|
||||
type initial struct {
|
||||
}
|
||||
|
||||
func New() modechanger.Process {
|
||||
func New() mode.Process {
|
||||
return &initial{}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,6 @@ func (i *initial) Close(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (i *initial) CanTransition(next modechanger.Mode) bool {
|
||||
func (i *initial) CanTransition(next mode.Mode) bool {
|
||||
return true
|
||||
}
|
|
@ -6,10 +6,10 @@ import (
|
|||
"github.com/anyproto/any-sync/app"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/space/components/builder"
|
||||
"github.com/anyproto/anytype-heart/space/components/spaceloader"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/builder"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spaceloader"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
)
|
||||
|
||||
type loader struct {
|
||||
|
@ -21,7 +21,7 @@ type LoadWaiter interface {
|
|||
}
|
||||
|
||||
type Loader interface {
|
||||
modechanger.Process
|
||||
mode.Process
|
||||
LoadWaiter
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ func (l *loader) Close(ctx context.Context) error {
|
|||
return l.app.Close(ctx)
|
||||
}
|
||||
|
||||
func (l *loader) CanTransition(next modechanger.Mode) bool {
|
||||
func (l *loader) CanTransition(next mode.Mode) bool {
|
||||
return true
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package modechanger
|
||||
package mode
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -5,13 +5,13 @@ import (
|
|||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/components/spaceoffloader"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/process/modechanger"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spaceoffloader"
|
||||
"github.com/anyproto/anytype-heart/space/internal/components/spacestatus"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/mode"
|
||||
)
|
||||
|
||||
type Offloader interface {
|
||||
modechanger.Process
|
||||
mode.Process
|
||||
WaitOffload(ctx context.Context) error
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ func (o *offloader) Start(ctx context.Context) error {
|
|||
return o.app.Start(ctx)
|
||||
}
|
||||
|
||||
func (o *offloader) CanTransition(next modechanger.Mode) bool {
|
||||
func (o *offloader) CanTransition(next mode.Mode) bool {
|
||||
return false
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/process/loader"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/loader"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
)
|
||||
|
||||
|
@ -26,10 +26,7 @@ func (s *service) startStatus(ctx context.Context, spaceID string, status spacei
|
|||
|
||||
func (s *service) waitLoad(ctx context.Context, ctrl spacecontroller.SpaceController) (sp clientspace.Space, err error) {
|
||||
if ld, ok := ctrl.Current().(loader.LoadWaiter); ok {
|
||||
sp, err = ld.WaitLoad(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ld.WaitLoad(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("failed to load space")
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package space
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/localstore/addr"
|
||||
)
|
||||
|
||||
func (s *service) initMarketplaceSpace(ctx context.Context) error {
|
||||
ctrl, err := s.factory.CreateMarketplaceSpace(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ctrl.Start(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.spaceControllers[addr.AnytypeMarketplaceWorkspace] = ctrl
|
||||
return nil
|
||||
}
|
|
@ -1,465 +0,0 @@
|
|||
// Code generated by mockery v2.35.2. DO NOT EDIT.
|
||||
|
||||
package mock_space
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
app "github.com/anyproto/any-sync/app"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
space "github.com/anyproto/anytype-heart/space"
|
||||
)
|
||||
|
||||
// MockService is an autogenerated mock type for the Service type
|
||||
type MockService struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockService_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockService) EXPECT() *MockService_Expecter {
|
||||
return &MockService_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Close provides a mock function with given fields: ctx
|
||||
func (_m *MockService) Close(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
|
||||
type MockService_Close_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Close is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockService_Expecter) Close(ctx interface{}) *MockService_Close_Call {
|
||||
return &MockService_Close_Call{Call: _e.mock.On("Close", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Close_Call) Run(run func(ctx context.Context)) *MockService_Close_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Close_Call) Return(err error) *MockService_Close_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Close_Call) RunAndReturn(run func(context.Context) error) *MockService_Close_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Create provides a mock function with given fields: ctx
|
||||
func (_m *MockService) Create(ctx context.Context) (space.Space, error) {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
var r0 space.Space
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) (space.Space, error)); ok {
|
||||
return rf(ctx)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context) space.Space); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(space.Space)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||
r1 = rf(ctx)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'
|
||||
type MockService_Create_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Create is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockService_Expecter) Create(ctx interface{}) *MockService_Create_Call {
|
||||
return &MockService_Create_Call{Call: _e.mock.On("Create", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Create_Call) Run(run func(ctx context.Context)) *MockService_Create_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Create_Call) Return(_a0 space.Space, err error) *MockService_Create_Call {
|
||||
_c.Call.Return(_a0, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Create_Call) RunAndReturn(run func(context.Context) (space.Space, error)) *MockService_Create_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Delete provides a mock function with given fields: ctx, id
|
||||
func (_m *MockService) Delete(ctx context.Context, id string) error {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete'
|
||||
type MockService_Delete_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Delete is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - id string
|
||||
func (_e *MockService_Expecter) Delete(ctx interface{}, id interface{}) *MockService_Delete_Call {
|
||||
return &MockService_Delete_Call{Call: _e.mock.On("Delete", ctx, id)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Delete_Call) Run(run func(ctx context.Context, id string)) *MockService_Delete_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Delete_Call) Return(err error) *MockService_Delete_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Delete_Call) RunAndReturn(run func(context.Context, string) error) *MockService_Delete_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: ctx, id
|
||||
func (_m *MockService) Get(ctx context.Context, id string) (space.Space, error) {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
var r0 space.Space
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) (space.Space, error)); ok {
|
||||
return rf(ctx, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) space.Space); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(space.Space)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
|
||||
type MockService_Get_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Get is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - id string
|
||||
func (_e *MockService_Expecter) Get(ctx interface{}, id interface{}) *MockService_Get_Call {
|
||||
return &MockService_Get_Call{Call: _e.mock.On("Get", ctx, id)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Get_Call) Run(run func(ctx context.Context, id string)) *MockService_Get_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Get_Call) Return(_a0 space.Space, err error) *MockService_Get_Call {
|
||||
_c.Call.Return(_a0, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Get_Call) RunAndReturn(run func(context.Context, string) (space.Space, error)) *MockService_Get_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetPersonalSpace provides a mock function with given fields: ctx
|
||||
func (_m *MockService) GetPersonalSpace(ctx context.Context) (space.Space, error) {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
var r0 space.Space
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) (space.Space, error)); ok {
|
||||
return rf(ctx)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context) space.Space); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(space.Space)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||
r1 = rf(ctx)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_GetPersonalSpace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonalSpace'
|
||||
type MockService_GetPersonalSpace_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetPersonalSpace is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockService_Expecter) GetPersonalSpace(ctx interface{}) *MockService_GetPersonalSpace_Call {
|
||||
return &MockService_GetPersonalSpace_Call{Call: _e.mock.On("GetPersonalSpace", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockService_GetPersonalSpace_Call) Run(run func(ctx context.Context)) *MockService_GetPersonalSpace_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_GetPersonalSpace_Call) Return(_a0 space.Space, err error) *MockService_GetPersonalSpace_Call {
|
||||
_c.Call.Return(_a0, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_GetPersonalSpace_Call) RunAndReturn(run func(context.Context) (space.Space, error)) *MockService_GetPersonalSpace_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Init provides a mock function with given fields: a
|
||||
func (_m *MockService) Init(a *app.App) error {
|
||||
ret := _m.Called(a)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(*app.App) error); ok {
|
||||
r0 = rf(a)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_Init_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Init'
|
||||
type MockService_Init_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Init is a helper method to define mock.On call
|
||||
// - a *app.App
|
||||
func (_e *MockService_Expecter) Init(a interface{}) *MockService_Init_Call {
|
||||
return &MockService_Init_Call{Call: _e.mock.On("Init", a)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Init_Call) Run(run func(a *app.App)) *MockService_Init_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(*app.App))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Init_Call) Return(err error) *MockService_Init_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Init_Call) RunAndReturn(run func(*app.App) error) *MockService_Init_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Name provides a mock function with given fields:
|
||||
func (_m *MockService) Name() string {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func() string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_Name_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Name'
|
||||
type MockService_Name_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Name is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) Name() *MockService_Name_Call {
|
||||
return &MockService_Name_Call{Call: _e.mock.On("Name")}
|
||||
}
|
||||
|
||||
func (_c *MockService_Name_Call) Run(run func()) *MockService_Name_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Name_Call) Return(name string) *MockService_Name_Call {
|
||||
_c.Call.Return(name)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Name_Call) RunAndReturn(run func() string) *MockService_Name_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Run provides a mock function with given fields: ctx
|
||||
func (_m *MockService) Run(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_Run_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Run'
|
||||
type MockService_Run_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Run is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockService_Expecter) Run(ctx interface{}) *MockService_Run_Call {
|
||||
return &MockService_Run_Call{Call: _e.mock.On("Run", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Run_Call) Run(run func(ctx context.Context)) *MockService_Run_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Run_Call) Return(err error) *MockService_Run_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Run_Call) RunAndReturn(run func(context.Context) error) *MockService_Run_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SpaceViewId provides a mock function with given fields: spaceId
|
||||
func (_m *MockService) SpaceViewId(spaceId string) (string, error) {
|
||||
ret := _m.Called(spaceId)
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return rf(spaceId)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(spaceId)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(spaceId)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_SpaceViewId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SpaceViewId'
|
||||
type MockService_SpaceViewId_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// SpaceViewId is a helper method to define mock.On call
|
||||
// - spaceId string
|
||||
func (_e *MockService_Expecter) SpaceViewId(spaceId interface{}) *MockService_SpaceViewId_Call {
|
||||
return &MockService_SpaceViewId_Call{Call: _e.mock.On("SpaceViewId", spaceId)}
|
||||
}
|
||||
|
||||
func (_c *MockService_SpaceViewId_Call) Run(run func(spaceId string)) *MockService_SpaceViewId_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_SpaceViewId_Call) Return(spaceViewId string, err error) *MockService_SpaceViewId_Call {
|
||||
_c.Call.Return(spaceViewId, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_SpaceViewId_Call) RunAndReturn(run func(string) (string, error)) *MockService_SpaceViewId_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockService(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockService {
|
||||
mock := &MockService{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -14,11 +14,11 @@ import (
|
|||
|
||||
"github.com/anyproto/anytype-heart/pkg/lib/localstore/addr"
|
||||
"github.com/anyproto/anytype-heart/space/clientspace"
|
||||
"github.com/anyproto/anytype-heart/space/components/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/process/loader"
|
||||
"github.com/anyproto/anytype-heart/space/spacefactory"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spacecontroller"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spacefactory"
|
||||
"github.com/anyproto/anytype-heart/space/internal/spaceprocess/loader"
|
||||
"github.com/anyproto/anytype-heart/space/internal/techspace"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
"github.com/anyproto/anytype-heart/space/techspace"
|
||||
)
|
||||
|
||||
const CName = "client.space"
|
||||
|
@ -86,6 +86,7 @@ func (s *service) Init(a *app.App) (err error) {
|
|||
s.newAccount = app.MustComponent[isNewAccount](a).IsNewAccount()
|
||||
coordClient := app.MustComponent[coordinatorclient.CoordinatorClient](a)
|
||||
s.delController = newDeletionController(s, coordClient)
|
||||
s.factory = app.MustComponent[spacefactory.SpaceFactory](a)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ import (
|
|||
|
||||
"github.com/anyproto/anytype-heart/core/block/object/objectcache/mock_objectcache"
|
||||
"github.com/anyproto/anytype-heart/core/domain"
|
||||
"github.com/anyproto/anytype-heart/space/internal/techspace/mock_techspace"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spacecore/mock_spacecore"
|
||||
"github.com/anyproto/anytype-heart/space/spaceinfo"
|
||||
"github.com/anyproto/anytype-heart/space/techspace/mock_techspace"
|
||||
"github.com/anyproto/anytype-heart/tests/testutil"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package space
|
||||
|
||||
func (s *service) initTechSpace() (err error) {
|
||||
s.techSpace, err = s.factory.CreateAndSetTechSpace(s.ctx)
|
||||
return
|
||||
}
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore"
|
||||
)
|
||||
|
||||
const virtualSpaceServiceName = "virtualSpaceService"
|
||||
const CName = "common.space.virtualspaceservice"
|
||||
|
||||
type VirtualSpaceService interface {
|
||||
app.ComponentRunnable
|
||||
|
@ -25,7 +25,7 @@ func (v *virtualSpaceService) Init(a *app.App) (err error) {
|
|||
}
|
||||
|
||||
func (v *virtualSpaceService) Name() string {
|
||||
return virtualSpaceServiceName
|
||||
return CName
|
||||
}
|
||||
|
||||
func (v *virtualSpaceService) Run(ctx context.Context) (err error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue