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:
parent
56e09a1a69
commit
bb27b8e44d
@ -19,26 +19,26 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ inject.ServiceHandler = &groupsHandler{}
|
var _ inject.ServiceHandler = &baseGroupsHandler{}
|
||||||
|
|
||||||
func NewGroupsHandler(
|
func NewGroupsHandler(
|
||||||
opts control.Options,
|
opts control.Options,
|
||||||
) *groupsHandler {
|
) *baseGroupsHandler {
|
||||||
return &groupsHandler{
|
return &baseGroupsHandler{
|
||||||
opts: opts,
|
opts: opts,
|
||||||
backupDriveIDNames: idname.NewCache(nil),
|
backupDriveIDNames: idname.NewCache(nil),
|
||||||
backupSiteIDWebURL: idname.NewCache(nil),
|
backupSiteIDWebURL: idname.NewCache(nil),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type groupsHandler struct {
|
type baseGroupsHandler struct {
|
||||||
opts control.Options
|
opts control.Options
|
||||||
|
|
||||||
backupDriveIDNames idname.CacheBuilder
|
backupDriveIDNames idname.CacheBuilder
|
||||||
backupSiteIDWebURL idname.CacheBuilder
|
backupSiteIDWebURL idname.CacheBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *groupsHandler) CacheItemInfo(v details.ItemInfo) {
|
func (h *baseGroupsHandler) CacheItemInfo(v details.ItemInfo) {
|
||||||
if v.Groups == nil {
|
if v.Groups == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func (h *groupsHandler) CacheItemInfo(v details.ItemInfo) {
|
|||||||
|
|
||||||
// ProduceExportCollections will create the export collections for the
|
// ProduceExportCollections will create the export collections for the
|
||||||
// given restore collections.
|
// given restore collections.
|
||||||
func (h *groupsHandler) ProduceExportCollections(
|
func (h *baseGroupsHandler) ProduceExportCollections(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
backupVersion int,
|
backupVersion int,
|
||||||
exportCfg control.ExportConfig,
|
exportCfg control.ExportConfig,
|
||||||
|
|||||||
@ -15,25 +15,25 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ inject.ServiceHandler = &onedriveHandler{}
|
var _ inject.ServiceHandler = &baseOnedriveHandler{}
|
||||||
|
|
||||||
func NewOneDriveHandler(
|
func NewOneDriveHandler(
|
||||||
opts control.Options,
|
opts control.Options,
|
||||||
) *onedriveHandler {
|
) *baseOnedriveHandler {
|
||||||
return &onedriveHandler{
|
return &baseOnedriveHandler{
|
||||||
opts: opts,
|
opts: opts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type onedriveHandler struct {
|
type baseOnedriveHandler struct {
|
||||||
opts control.Options
|
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
|
// ProduceExportCollections will create the export collections for the
|
||||||
// given restore collections.
|
// given restore collections.
|
||||||
func (h *onedriveHandler) ProduceExportCollections(
|
func (h *baseOnedriveHandler) ProduceExportCollections(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
backupVersion int,
|
backupVersion int,
|
||||||
exportCfg control.ExportConfig,
|
exportCfg control.ExportConfig,
|
||||||
|
|||||||
@ -17,23 +17,23 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ inject.ServiceHandler = &sharepointHandler{}
|
var _ inject.ServiceHandler = &baseSharepointHandler{}
|
||||||
|
|
||||||
func NewSharePointHandler(
|
func NewSharePointHandler(
|
||||||
opts control.Options,
|
opts control.Options,
|
||||||
) *sharepointHandler {
|
) *baseSharepointHandler {
|
||||||
return &sharepointHandler{
|
return &baseSharepointHandler{
|
||||||
opts: opts,
|
opts: opts,
|
||||||
backupDriveIDNames: idname.NewCache(nil),
|
backupDriveIDNames: idname.NewCache(nil),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type sharepointHandler struct {
|
type baseSharepointHandler struct {
|
||||||
opts control.Options
|
opts control.Options
|
||||||
backupDriveIDNames idname.CacheBuilder
|
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.
|
// Old versions would store SharePoint data as OneDrive.
|
||||||
switch {
|
switch {
|
||||||
case v.SharePoint != nil:
|
case v.SharePoint != nil:
|
||||||
@ -46,7 +46,7 @@ func (h *sharepointHandler) CacheItemInfo(v details.ItemInfo) {
|
|||||||
|
|
||||||
// ProduceExportCollections will create the export collections for the
|
// ProduceExportCollections will create the export collections for the
|
||||||
// given restore collections.
|
// given restore collections.
|
||||||
func (h *sharepointHandler) ProduceExportCollections(
|
func (h *baseSharepointHandler) ProduceExportCollections(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
backupVersion int,
|
backupVersion int,
|
||||||
exportCfg control.ExportConfig,
|
exportCfg control.ExportConfig,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user