simplefile

package
v0.0.0-...-ca3ac9b Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package simplefile implement a storage system on a mounted device with simple files as storage objects

Index

Constants

View Source
const (
	// DescriptionExt extension of the description file
	DescriptionExt = ".json"
	// BinaryExt extension of the binary file
	BinaryExt = ".bin"
	// RetentionExt extension of the retention file
	RetentionExt = ".json"
	// RetentionPath path to the retention files
	RetentionPath = "retention"
)

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
	ErrSrvNotFound    = errors.New("service not found")
)

defining some error

Functions

This section is empty.

Types

type BlobStorage

type BlobStorage struct {
	RootPath string // this is the root path for the file system storage
	Tenant   string // this is the tenant, on which this service will work
	// contains filtered or unexported fields
}

BlobStorage service for storing blob files into a file system

func (*BlobStorage) AddRetention

func (s *BlobStorage) AddRetention(r *model.RetentionEntry) error

AddRetention adding a retention entry to the storage

func (*BlobStorage) CheckBlob

func (s *BlobStorage) CheckBlob(id string) (*model.CheckInfo, error)

CheckBlob checking a single blob from the storage system

func (*BlobStorage) Close

func (s *BlobStorage) Close() error

Close closing the storage

func (*BlobStorage) DeleteBlob

func (s *BlobStorage) DeleteBlob(id string) error

DeleteBlob removing a blob from the storage system

func (*BlobStorage) DeleteRetention

func (s *BlobStorage) DeleteRetention(id string) error

DeleteRetention deletes the retention entry from the storage

func (*BlobStorage) GetAllRetentions

func (s *BlobStorage) GetAllRetentions(callback func(r model.RetentionEntry) bool) error

GetAllRetentions for every retention entry for this tenant we call this this function, you can stop the listing by returnong a false

func (*BlobStorage) GetBlobDescription

func (s *BlobStorage) GetBlobDescription(id string) (*model.BlobDescription, error)

GetBlobDescription getting the description of the file

func (*BlobStorage) GetBlobs

func (s *BlobStorage) GetBlobs(callback func(id string) bool) error

GetBlobs getting a list of blob from the filesystem

func (*BlobStorage) GetLastError

func (s *BlobStorage) GetLastError() error

GetLastError returning the last error (niy)

func (*BlobStorage) GetRetention

func (s *BlobStorage) GetRetention(id string) (model.RetentionEntry, error)

GetRetention getting a single retention entry

func (*BlobStorage) GetTenant

func (s *BlobStorage) GetTenant() string

GetTenant return the id of the tenant

func (*BlobStorage) HasBlob

func (s *BlobStorage) HasBlob(id string) (bool, error)

HasBlob checking, if a blob is present

func (*BlobStorage) Init

func (s *BlobStorage) Init() error

Init initialize this service

func (*BlobStorage) ResetRetention

func (s *BlobStorage) ResetRetention(id string) error

ResetRetention resets the retention for a blob

func (*BlobStorage) RetrieveBlob

func (s *BlobStorage) RetrieveBlob(id string, writer io.Writer) error

RetrieveBlob retrieving the binary data from the storage system

func (*BlobStorage) SearchBlobs

func (s *BlobStorage) SearchBlobs(_ string, _ func(id string) bool) error

SearchBlobs querying a single blob, niy

func (*BlobStorage) StoreBlob

func (s *BlobStorage) StoreBlob(b *model.BlobDescription, f io.Reader) (string, error)

StoreBlob storing a blob to the storage system

func (*BlobStorage) UpdateBlobDescription

func (s *BlobStorage) UpdateBlobDescription(id string, b *model.BlobDescription) error

UpdateBlobDescription updating the blob description

type MultiVolumeStorage

type MultiVolumeStorage struct {
	RootPath string // this is the root path for the file system storage
	Tenant   string // this is the tenant, on which this service will work
	// contains filtered or unexported fields
}

MultiVolumeStorage this service takes multi volumes and treats them as a single file storage

func (*MultiVolumeStorage) AddRetention

func (s *MultiVolumeStorage) AddRetention(r *model.RetentionEntry) error

AddRetention adding a retention entry to the storage

func (*MultiVolumeStorage) CheckBlob

func (s *MultiVolumeStorage) CheckBlob(id string) (*model.CheckInfo, error)

CheckBlob checking a single blob from the storage system

func (*MultiVolumeStorage) Close

func (s *MultiVolumeStorage) Close() error

Close closing the storage

func (*MultiVolumeStorage) DeleteBlob

func (s *MultiVolumeStorage) DeleteBlob(id string) error

DeleteBlob removing a blob from the storage system

func (*MultiVolumeStorage) DeleteRetention

func (s *MultiVolumeStorage) DeleteRetention(id string) error

DeleteRetention deletes the retention entry from the storage

func (*MultiVolumeStorage) GetAllRetentions

func (s *MultiVolumeStorage) GetAllRetentions(callback func(r model.RetentionEntry) bool) error

GetAllRetentions for every retention entry for this tenant we call this this function, you can stop the listing by returning a false

func (*MultiVolumeStorage) GetBlobDescription

func (s *MultiVolumeStorage) GetBlobDescription(id string) (*model.BlobDescription, error)

GetBlobDescription getting the lob description from the service holding the blob

func (*MultiVolumeStorage) GetBlobs

func (s *MultiVolumeStorage) GetBlobs(callback func(id string) bool) error

GetBlobs walking thru all blobs of this tenant

func (*MultiVolumeStorage) GetLastError

func (s *MultiVolumeStorage) GetLastError() error

GetLastError returning the last error (niy)

func (*MultiVolumeStorage) GetRetention

func (s *MultiVolumeStorage) GetRetention(id string) (model.RetentionEntry, error)

GetRetention getting a single retention entry

func (*MultiVolumeStorage) GetTenant

func (s *MultiVolumeStorage) GetTenant() string

GetTenant return the id of the tenant

func (*MultiVolumeStorage) HasBlob

func (s *MultiVolumeStorage) HasBlob(id string) (bool, error)

HasBlob checking if one service has this blob

func (*MultiVolumeStorage) Init

func (s *MultiVolumeStorage) Init() error

Init initialize this service

func (*MultiVolumeStorage) ResetRetention

func (s *MultiVolumeStorage) ResetRetention(id string) error

ResetRetention resets the retention for a blob

func (*MultiVolumeStorage) RetrieveBlob

func (s *MultiVolumeStorage) RetrieveBlob(id string, writer io.Writer) error

RetrieveBlob retrieving the blob from the first service holding the blob file

func (*MultiVolumeStorage) SearchBlobs

func (s *MultiVolumeStorage) SearchBlobs(_ string, _ func(id string) bool) error

SearchBlobs is not implemented for this storage

func (*MultiVolumeStorage) StoreBlob

func (s *MultiVolumeStorage) StoreBlob(b *model.BlobDescription, f io.Reader) (string, error)

StoreBlob storing a blob to the storage system

func (*MultiVolumeStorage) UpdateBlobDescription

func (s *MultiVolumeStorage) UpdateBlobDescription(_ string, _ *model.BlobDescription) error

UpdateBlobDescription updating the blob description TODO implement this

type TenantInfo

type TenantInfo struct {
	ID   string
	Size int64
}

TenantInfo entry for tenant list

type TenantManager

type TenantManager struct {
	RootPath    string // this is the root path for the file system storage
	TenantInfos sync.Map
	// contains filtered or unexported fields
}

TenantManager the tenant manager based on a simple file storage system

func (*TenantManager) AddSize

func (s *TenantManager) AddSize(tenant string, size int64)

AddSize adding the blob size to the tenant size

func (*TenantManager) AddTenant

func (s *TenantManager) AddTenant(tenant string) error

AddTenant add a new tenant to the manager

func (*TenantManager) Close

func (s *TenantManager) Close() error

Close closing this service

func (*TenantManager) GetConfig

func (s *TenantManager) GetConfig(tenant string) (*interfaces.TenantConfig, error)

GetConfig reading the config object for the tenant

func (*TenantManager) GetSize

func (s *TenantManager) GetSize(tenant string) int64

GetSize getting the overall storage size for a tenant

func (*TenantManager) GetTenants

func (s *TenantManager) GetTenants(callback func(tenant string) bool) error

GetTenants walk thru all tenants

func (*TenantManager) HasTenant

func (s *TenantManager) HasTenant(tenant string) bool

HasTenant checking is a tenant is created

func (*TenantManager) Init

func (s *TenantManager) Init() error

Init intialise this tenant manager

func (*TenantManager) RemoveTenant

func (s *TenantManager) RemoveTenant(tenant string) (string, error)

RemoveTenant remove a tenant from the service, delete all related data

func (*TenantManager) SetConfig

func (s *TenantManager) SetConfig(tenant string, config interfaces.TenantConfig) error

SetConfig writing a new config object for the tenant

func (*TenantManager) SubSize

func (s *TenantManager) SubSize(tenant string, size int64)

SubSize subtract the blob size to the tenant size

Jump to

Keyboard shortcuts

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