Rename service handlers (#4571)

Rename these handlers to be base<Service>Handler so that we get some segmentation of functionality. This will allow us a bit of compile-time safety when it comes to accessing graph because the base handler doesn't contain a client instance. Essentially it allows us local access to things for operations like restore.

Future additions to the handler that require a client should wrap this base handler to provide that functionality. Export functions shouldn't be updated to be part of the new handler wrapper but should stay as part of the base handler so they continue to not have access to graph.

---

#### 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

- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

#### Issue(s)

* #4254

#### Test Plan

- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-11-13 15:08:14 -08:00 committed by GitHub
parent 56e09a1a69
commit bb27b8e44d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 18 deletions

View File

@ -19,26 +19,26 @@ import (
"github.com/alcionai/corso/src/pkg/path"
)
var _ inject.ServiceHandler = &groupsHandler{}
var _ inject.ServiceHandler = &baseGroupsHandler{}
func NewGroupsHandler(
opts control.Options,
) *groupsHandler {
return &groupsHandler{
) *baseGroupsHandler {
return &baseGroupsHandler{
opts: opts,
backupDriveIDNames: idname.NewCache(nil),
backupSiteIDWebURL: idname.NewCache(nil),
}
}
type groupsHandler struct {
type baseGroupsHandler struct {
opts control.Options
backupDriveIDNames idname.CacheBuilder
backupSiteIDWebURL idname.CacheBuilder
}
func (h *groupsHandler) CacheItemInfo(v details.ItemInfo) {
func (h *baseGroupsHandler) CacheItemInfo(v details.ItemInfo) {
if v.Groups == nil {
return
}
@ -49,7 +49,7 @@ func (h *groupsHandler) CacheItemInfo(v details.ItemInfo) {
// ProduceExportCollections will create the export collections for the
// given restore collections.
func (h *groupsHandler) ProduceExportCollections(
func (h *baseGroupsHandler) ProduceExportCollections(
ctx context.Context,
backupVersion int,
exportCfg control.ExportConfig,

View File

@ -15,25 +15,25 @@ import (
"github.com/alcionai/corso/src/pkg/path"
)
var _ inject.ServiceHandler = &onedriveHandler{}
var _ inject.ServiceHandler = &baseOnedriveHandler{}
func NewOneDriveHandler(
opts control.Options,
) *onedriveHandler {
return &onedriveHandler{
) *baseOnedriveHandler {
return &baseOnedriveHandler{
opts: opts,
}
}
type onedriveHandler struct {
type baseOnedriveHandler struct {
opts control.Options
}
func (h *onedriveHandler) CacheItemInfo(v details.ItemInfo) {}
func (h *baseOnedriveHandler) CacheItemInfo(v details.ItemInfo) {}
// ProduceExportCollections will create the export collections for the
// given restore collections.
func (h *onedriveHandler) ProduceExportCollections(
func (h *baseOnedriveHandler) ProduceExportCollections(
ctx context.Context,
backupVersion int,
exportCfg control.ExportConfig,

View File

@ -17,23 +17,23 @@ import (
"github.com/alcionai/corso/src/pkg/path"
)
var _ inject.ServiceHandler = &sharepointHandler{}
var _ inject.ServiceHandler = &baseSharepointHandler{}
func NewSharePointHandler(
opts control.Options,
) *sharepointHandler {
return &sharepointHandler{
) *baseSharepointHandler {
return &baseSharepointHandler{
opts: opts,
backupDriveIDNames: idname.NewCache(nil),
}
}
type sharepointHandler struct {
type baseSharepointHandler struct {
opts control.Options
backupDriveIDNames idname.CacheBuilder
}
func (h *sharepointHandler) CacheItemInfo(v details.ItemInfo) {
func (h *baseSharepointHandler) CacheItemInfo(v details.ItemInfo) {
// Old versions would store SharePoint data as OneDrive.
switch {
case v.SharePoint != nil:
@ -46,7 +46,7 @@ func (h *sharepointHandler) CacheItemInfo(v details.ItemInfo) {
// ProduceExportCollections will create the export collections for the
// given restore collections.
func (h *sharepointHandler) ProduceExportCollections(
func (h *baseSharepointHandler) ProduceExportCollections(
ctx context.Context,
backupVersion int,
exportCfg control.ExportConfig,