corso/src/internal/m365/mock/connector.go
Keepers 2a150cc610
add counter for skip-collision counting (#3722)
Introduces a counting bus, and threads it into restore operations so that we can count the number of
collision skips that occur.

---

#### Does this PR need a docs update or release note?

- [x]  No

#### Type of change

- [x] 🌻 Feature

#### Issue(s)

* #3562

#### Test Plan

- [x]  Unit test
- [x] 💚 E2E
2023-07-06 19:22:02 +00:00

72 lines
1.5 KiB
Go

package mock
import (
"context"
"github.com/alcionai/corso/src/internal/common/idname"
"github.com/alcionai/corso/src/internal/common/prefixmatcher"
"github.com/alcionai/corso/src/internal/data"
"github.com/alcionai/corso/src/internal/operations/inject"
"github.com/alcionai/corso/src/pkg/backup/details"
"github.com/alcionai/corso/src/pkg/control"
"github.com/alcionai/corso/src/pkg/count"
"github.com/alcionai/corso/src/pkg/fault"
"github.com/alcionai/corso/src/pkg/path"
"github.com/alcionai/corso/src/pkg/selectors"
)
var _ inject.BackupProducer = &Controller{}
type Controller struct {
Collections []data.BackupCollection
Exclude *prefixmatcher.StringSetMatcher
Deets *details.Details
Err error
Stats data.CollectionStats
}
func (ctrl Controller) ProduceBackupCollections(
_ context.Context,
_ idname.Provider,
_ selectors.Selector,
_ []data.RestoreCollection,
_ int,
_ control.Options,
_ *fault.Bus,
) (
[]data.BackupCollection,
prefixmatcher.StringSetReader,
bool,
error,
) {
return ctrl.Collections, ctrl.Exclude, ctrl.Err == nil, ctrl.Err
}
func (ctrl Controller) IsBackupRunnable(
_ context.Context,
_ path.ServiceType,
_ string,
) (bool, error) {
return true, ctrl.Err
}
func (ctrl Controller) Wait() *data.CollectionStats {
return &ctrl.Stats
}
func (ctrl Controller) ConsumeRestoreCollections(
_ context.Context,
_ int,
_ selectors.Selector,
_ control.RestoreConfig,
_ control.Options,
_ []data.RestoreCollection,
_ *fault.Bus,
_ *count.Bus,
) (*details.Details, error) {
return ctrl.Deets, ctrl.Err
}