storage

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessControl

type AccessControl interface {
	CheckAccess(userID, tenantID, resource, action string) bool
	LogAccess(userID, tenantID, resource, action, details string)
	GetAuditLogs() []StorageAuditLogEntry
	GetTenantAuditLogs(tenantID string) []StorageAuditLogEntry
	GetVolumeAuditLogs(volumeName string) []StorageAuditLogEntry
}

AccessControl handles access control for storage

type EncryptionManager

type EncryptionManager interface {
	Encrypt(tenantID *string, data []byte) ([]byte, error)
	Decrypt(tenantID *string, encryptedData []byte) ([]byte, error)
}

EncryptionManager handles encryption of data

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles storage operations

func NewManager

func NewManager(dataDir string, logger *logrus.Logger) (*Manager, error)

NewManager creates a new storage manager

func (*Manager) BackupVolume

func (m *Manager) BackupVolume(name, outputPath string) error

BackupVolume backs up a volume to a file

func (*Manager) CloneVolume

func (m *Manager) CloneVolume(ctx context.Context, sourceName, targetName string) error

CloneVolume clones a volume

func (*Manager) Close

func (m *Manager) Close() error

Close closes the storage manager

func (*Manager) CreateVolume

func (m *Manager) CreateVolume(ctx context.Context, options interface{}) (interface{}, error)

CreateVolumeInterface is an adapter method to match the app.StorageManager interface

func (*Manager) CreateVolumeSimple

func (m *Manager) CreateVolumeSimple(ctx context.Context, name string, size int64) (*VolumeStatus, error)

CreateVolumeSimple creates a new volume with just a name and size

func (*Manager) CreateVolumeSimpleInterface

func (m *Manager) CreateVolumeSimpleInterface(ctx context.Context, name string, size int64) (interface{}, error)

CreateVolumeSimpleInterface is an adapter method to match the app.StorageManager interface

func (*Manager) CreateVolumeWithOptions

func (m *Manager) CreateVolumeWithOptions(ctx context.Context, options VolumeOptions) (*VolumeStatus, error)

CreateVolumeWithOptions creates a new volume

func (*Manager) DecryptData

func (m *Manager) DecryptData(tenantID *string, encryptedData []byte) ([]byte, error)

DecryptData decrypts data for a tenant

func (*Manager) DeleteNode

func (m *Manager) DeleteNode(id string) error

DeleteNode deletes a node from the database

func (*Manager) DeleteVolume

func (m *Manager) DeleteVolume(name string) error

DeleteVolume deletes a volume from the database

func (*Manager) DeleteVolumeWithContext

func (m *Manager) DeleteVolumeWithContext(ctx context.Context, name string) error

DeleteVolumeWithContext deletes a volume with context

func (*Manager) DeleteVolumeWithOptions

func (m *Manager) DeleteVolumeWithOptions(ctx context.Context, name, userID, tenantID string) error

DeleteVolumeWithOptions deletes a volume with options

func (*Manager) EncryptData

func (m *Manager) EncryptData(tenantID *string, data []byte) ([]byte, error)

EncryptData encrypts data for a tenant

func (*Manager) GetNodes

func (m *Manager) GetNodes() ([]struct {
	ID       string
	Address  string
	JoinedAt int64
}, error)

GetNodes returns all nodes

func (*Manager) GetStorageAuditLogs

func (m *Manager) GetStorageAuditLogs() []StorageAuditLogEntry

GetStorageAuditLogs returns storage audit logs

func (*Manager) GetTenantStorageAuditLogs

func (m *Manager) GetTenantStorageAuditLogs(tenantID string) []StorageAuditLogEntry

GetTenantStorageAuditLogs returns storage audit logs for a tenant

func (*Manager) GetTenantStorageStats

func (m *Manager) GetTenantStorageStats(tenantID string) *TenantStorageStats

GetTenantStorageStats returns storage stats for a tenant

func (*Manager) GetTenantStorageUsage

func (m *Manager) GetTenantStorageUsage(ctx context.Context, tenantID string) (int64, error)

GetTenantStorageUsage returns the storage usage for a tenant

func (*Manager) GetTotalStorageUsage

func (m *Manager) GetTotalStorageUsage(ctx context.Context) (int64, error)

GetTotalStorageUsage returns the total storage usage

func (*Manager) GetVolumeAuditLogs

func (m *Manager) GetVolumeAuditLogs(volumeName string) []StorageAuditLogEntry

GetVolumeAuditLogs returns storage audit logs for a volume

func (*Manager) GetVolumeMetadata

func (m *Manager) GetVolumeMetadata(ctx context.Context, volumeName string) (map[string]string, error)

GetVolumeMetadata gets metadata for a volume

func (*Manager) GetVolumeStatus

func (m *Manager) GetVolumeStatus(name string) (*VolumeStatus, error)

GetVolumeStatus returns the status of a volume

func (*Manager) GetVolumeUsage

func (m *Manager) GetVolumeUsage(ctx context.Context, volumeName string) (int64, error)

GetVolumeUsage returns the usage of a volume

func (*Manager) GetVolumes

func (m *Manager) GetVolumes() ([]VolumeStatus, error)

GetVolumes returns all volumes

func (*Manager) IsVolumeInUse

func (m *Manager) IsVolumeInUse(name string) (bool, error)

IsVolumeInUse checks if a volume is in use

func (*Manager) ListVolumes

func (m *Manager) ListVolumes(ctx context.Context) ([]VolumeStatus, error)

ListVolumes returns all volumes with context

func (*Manager) ListVolumesInterface

func (m *Manager) ListVolumesInterface(ctx context.Context) ([]interface{}, error)

ListVolumesInterface is an adapter method to match the app.StorageManager interface

func (*Manager) MonitorVolumeHealth

func (m *Manager) MonitorVolumeHealth(ctx context.Context, volumeName string) error

MonitorVolumeHealth monitors the health of a volume

func (*Manager) MountVolume

func (m *Manager) MountVolume(ctx context.Context, volumeName, containerID, mountPath string) error

MountVolume mounts a volume to a container

func (*Manager) ReadFromVolume

func (m *Manager) ReadFromVolume(ctx context.Context, volumeName string, offset, length int64) ([]byte, error)

ReadFromVolume reads data from a volume

func (*Manager) ResizeVolume

func (m *Manager) ResizeVolume(ctx context.Context, name string, newSize int64) error

ResizeVolume resizes a volume

func (*Manager) RestoreVolume

func (m *Manager) RestoreVolume(name, inputPath string) error

RestoreVolume restores a volume from a backup file

func (*Manager) RestoreVolumeFromSnapshot

func (m *Manager) RestoreVolumeFromSnapshot(ctx context.Context, volumeName, snapshotName string) error

RestoreVolumeFromSnapshot restores a volume from a snapshot

func (*Manager) SaveNode

func (m *Manager) SaveNode(id, address string, joinedAt int64) error

SaveNode saves node information to the database

func (*Manager) SaveVolume

func (m *Manager) SaveVolume(name, path string, size, createdAt int64) error

SaveVolume saves volume information to the database

func (*Manager) SetTenantStorageRateLimit

func (m *Manager) SetTenantStorageRateLimit(tenantID string, rateLimit uint32) error

SetTenantStorageRateLimit sets the rate limit for a tenant

func (*Manager) SetVolumeMetadata

func (m *Manager) SetVolumeMetadata(ctx context.Context, volumeName string, metadata map[string]string) error

SetVolumeMetadata sets metadata for a volume

func (*Manager) SnapshotVolume

func (m *Manager) SnapshotVolume(ctx context.Context, volumeName, snapshotName string) error

SnapshotVolume creates a snapshot of a volume

func (*Manager) StartVolumeHealthMonitoring

func (m *Manager) StartVolumeHealthMonitoring(ctx context.Context, interval time.Duration)

StartVolumeHealthMonitoring starts monitoring the health of all volumes

func (*Manager) UnmountVolume

func (m *Manager) UnmountVolume(ctx context.Context, volumeName, containerID string) error

UnmountVolume unmounts a volume from a container

func (*Manager) UpdateNodeResources

func (m *Manager) UpdateNodeResources(nodeID string, cpu int, memory int, disk int64) error

UpdateNodeResources updates the resources of a node in the database

func (*Manager) UpdateNodeStatus

func (m *Manager) UpdateNodeStatus(nodeID string, status string) error

UpdateNodeStatus updates the status of a node in the database

func (*Manager) UpdateVolumeState

func (m *Manager) UpdateVolumeState(name string, state VolumeState) error

UpdateVolumeState updates the state of a volume

func (*Manager) WithAccessControl

func (m *Manager) WithAccessControl(accessControl AccessControl) *Manager

WithAccessControl sets the access control

func (*Manager) WithEncryptionManager

func (m *Manager) WithEncryptionManager(encryptionManager EncryptionManager) *Manager

WithEncryptionManager sets the encryption manager

func (*Manager) WithQoSManager

func (m *Manager) WithQoSManager(qosManager QoSManager) *Manager

WithQoSManager sets the QoS manager

func (*Manager) WriteToVolume

func (m *Manager) WriteToVolume(ctx context.Context, volumeName string, data []byte, offset int64) error

WriteToVolume writes data to a volume

type QoSManager

type QoSManager interface {
	SetTenantRateLimit(tenantID string, rateLimit uint32) error
	GetTenantStats(tenantID string) *TenantStorageStats
}

QoSManager handles quality of service for storage

type StorageAuditLogEntry

type StorageAuditLogEntry struct {
	Timestamp int64
	Action    string
	UserID    string
	TenantID  string
	Resource  string
	Details   string
}

StorageAuditLogEntry represents an entry in the storage audit log

type TenantStorageStats

type TenantStorageStats struct {
	TotalSize      int64
	UsedSize       int64
	VolumeCount    int
	ReadOps        int64
	WriteOps       int64
	ReadBytes      int64
	WriteBytes     int64
	LastUpdateTime int64
}

TenantStorageStats represents storage statistics for a tenant

type VolumeOptions

type VolumeOptions struct {
	Name     string
	Size     int64
	TenantID string
	UserID   string
	Metadata map[string]string
}

VolumeOptions represents options for creating a volume

type VolumeState

type VolumeState string

VolumeState represents the state of a volume

const (
	// VolumeStateAvailable indicates the volume is available
	VolumeStateAvailable VolumeState = "available"
	// VolumeStateInUse indicates the volume is in use
	VolumeStateInUse VolumeState = "in_use"
	// VolumeStateFailed indicates the volume has failed
	VolumeStateFailed VolumeState = "failed"
)

type VolumeStatus

type VolumeStatus struct {
	Name      string
	Path      string
	Size      int64
	CreatedAt int64
	State     VolumeState
}

VolumeStatus represents the status of a volume

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL