-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luke Lombardi
committed
Mar 6, 2025
1 parent
239daeb
commit 3d18ef8
Showing
1 changed file
with
31 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
package storage | ||
|
||
import ( | ||
"github.com/beam-cloud/beta9/pkg/common" | ||
"github.com/beam-cloud/beta9/pkg/types" | ||
) | ||
|
||
type StorageManager struct { | ||
storage map[string]Storage | ||
storage *common.SafeMap[Storage] | ||
appConfig types.AppConfig | ||
} | ||
|
||
func NewStorageManager() *StorageManager { | ||
func NewStorageManager(appConfig types.AppConfig) *StorageManager { | ||
return &StorageManager{ | ||
storage: make(map[string]Storage), | ||
storage: common.NewSafeMap[Storage](), | ||
appConfig: appConfig, | ||
} | ||
} | ||
|
||
func (s *StorageManager) CreateWorkspaceStorage(name string, storage Storage) { | ||
s.storage[name] = storage | ||
func (s *StorageManager) Create(name string, storage Storage) { | ||
s.storage.Set(name, storage) | ||
} | ||
|
||
func (s *StorageManager) Mount(name string) Storage { | ||
storage, ok := s.storage.Get(name) | ||
if !ok { | ||
return nil | ||
} | ||
|
||
storage.Mount("/mock") | ||
|
||
return storage | ||
} | ||
|
||
func (s *StorageManager) MountWorkspaceStorage(name string) Storage { | ||
return s.storage[name] | ||
func (s *StorageManager) Unmount(name string) { | ||
storage, ok := s.storage.Get(name) | ||
if !ok { | ||
return | ||
} | ||
|
||
storage.Unmount("/mock") | ||
s.storage.Delete(name) | ||
} |