Have a way to gather stats about the exported data.
Users can now call `ExportOperation.GetStats()` at the end of the run to get the stats for the operations. The data will be in the format `map[path.CategoryType]data.KindStats` whre `KindStats` is:
```go
type KindStats struct {
BytesRead int64
ResourceCount int64
}
```
---
#### Does this PR need a docs update or release note?
- [ ] ✅ Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x] ⛔ No
#### Type of change
<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup
#### Issue(s)
<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* https://github.com/alcionai/corso/issues/4311
#### Test Plan
<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x] ⚡ Unit test
- [ ] 💚 E2E
107 lines
2.5 KiB
Go
107 lines
2.5 KiB
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/alcionai/clues"
|
|
|
|
"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/kopia"
|
|
kinject "github.com/alcionai/corso/src/internal/kopia/inject"
|
|
"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/export"
|
|
"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
|
|
|
|
ProtectedResourceID string
|
|
ProtectedResourceName string
|
|
ProtectedResourceErr error
|
|
}
|
|
|
|
func (ctrl Controller) ProduceBackupCollections(
|
|
_ context.Context,
|
|
_ inject.BackupProducerConfig,
|
|
_ *fault.Bus,
|
|
) (
|
|
[]data.BackupCollection,
|
|
prefixmatcher.StringSetReader,
|
|
bool,
|
|
error,
|
|
) {
|
|
return ctrl.Collections, ctrl.Exclude, ctrl.Err == nil, ctrl.Err
|
|
}
|
|
|
|
func (ctrl *Controller) GetMetadataPaths(
|
|
ctx context.Context,
|
|
r kinject.RestoreProducer,
|
|
man kopia.ManifestEntry,
|
|
errs *fault.Bus,
|
|
) ([]path.RestorePaths, error) {
|
|
return nil, clues.New("not implemented")
|
|
}
|
|
|
|
func (ctrl Controller) IsServiceEnabled(
|
|
_ 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,
|
|
_ inject.RestoreConsumerConfig,
|
|
_ []data.RestoreCollection,
|
|
_ *fault.Bus,
|
|
_ *count.Bus,
|
|
) (*details.Details, error) {
|
|
return ctrl.Deets, ctrl.Err
|
|
}
|
|
|
|
func (ctrl Controller) CacheItemInfo(dii details.ItemInfo) {}
|
|
|
|
func (ctrl Controller) ProduceExportCollections(
|
|
_ context.Context,
|
|
_ int,
|
|
_ selectors.Selector,
|
|
_ control.ExportConfig,
|
|
_ control.Options,
|
|
_ []data.RestoreCollection,
|
|
_ *data.ExportStats,
|
|
_ *fault.Bus,
|
|
) ([]export.Collectioner, error) {
|
|
return nil, ctrl.Err
|
|
}
|
|
|
|
func (ctrl Controller) PopulateProtectedResourceIDAndName(
|
|
ctx context.Context,
|
|
protectedResource string, // input value, can be either id or name
|
|
ins idname.Cacher,
|
|
) (idname.Provider, error) {
|
|
return idname.NewProvider(ctrl.ProtectedResourceID, ctrl.ProtectedResourceName),
|
|
ctrl.ProtectedResourceErr
|
|
}
|