Documentation
¶
Index ¶
- func DeleteBucket(db *sql.DB, bucketID string, store sharding.ShardStore, logger *zap.Logger) error
- func DeleteObject(db *sql.DB, bucketID, objectID string, store sharding.ShardStore, ...) error
- func DeleteObjectByVersion(db *sql.DB, bucketID, objectID, versionID string, store sharding.ShardStore, ...) error
- func DeleteVersionShardsAcrossNodes(bucketID, objectID, versionID string, store sharding.ShardStore, ...) error
- func IsValidZipFile(filePath string) (bool, error)
- func LookupStorageNodes(logger *zap.Logger) ([]string, error)
- func NewRetrieveData(db *sql.DB, bucketID, objectID, versionID string, store sharding.ShardStore, ...) ([]byte, string, error)
- func NewStoreData(db *sql.DB, data []byte, bucketID, objectID, filePath string, ...) (string, map[string]string, []string, error)
- func NewStoreDataWithVersion(db *sql.DB, data []byte, bucketID, objectID, versionID, filePath string, ...) (string, map[string]string, []string, error)
- func RetrieveData(db *sql.DB, bucketID, objectID, versionID string, store sharding.ShardStore, ...) ([]byte, string, error)
- func Retry(attempts int, sleep time.Duration, logger *zap.Logger, fn func() error) error
- func StoreData(db *sql.DB, data []byte, bucketID, objectID, filePath string, ...) (string, map[string]string, []string, error)
- func StoreDataWithVersion(db *sql.DB, data []byte, bucketID, objectID, versionID, filePath string, ...) (string, map[string]string, []string, error)
- func Unzip(source, target string) error
- func UpdateShardLocations(cfg *config.Config, bucketID, objectID, versionID string, ...) error
- func ZipDirectory(source, target string) error
- type NewStorage
- type ShardMetadata
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteBucket ¶
Delete a bucket
func DeleteObject ¶
func DeleteObject(db *sql.DB, bucketID, objectID string, store sharding.ShardStore, logger *zap.Logger) error
This should delete all versions of an object
func DeleteObjectByVersion ¶
func IsValidZipFile ¶
IsValidZipFile checks if the given file is a valid ZIP archive
func LookupStorageNodes ¶
LookupStorageNodes uses the discovery service to find storage nodes for a given key
func NewRetrieveData ¶
func NewRetrieveData(db *sql.DB, bucketID, objectID, versionID string, store sharding.ShardStore, cfg *config.Config, logger *zap.Logger) ([]byte, string, error)
NewRetrieveData fetches an object from storage nodes and reconstructs it The function looks up metadata, retrieves shards from storage nodes, reconstructs the data using erasure coding, then decrypts and decompresses it
func NewStoreData ¶
func NewStoreData( db *sql.DB, data []byte, bucketID, objectID, filePath string, store sharding.ShardStore, cfg *config.Config, locations []string, logger *zap.Logger) (string, map[string]string, []string, error)
NewStoreData stores an object by distributing it across storage nodes The function compresses, encrypts, shards, and distributes data across storage nodes It records metadata about shard locations and proofs in the database
func NewStoreDataWithVersion ¶
func NewStoreDataWithVersion(db *sql.DB, data []byte, bucketID, objectID, versionID, filePath string, store sharding.ShardStore, cfg *config.Config, locations []string, logger *zap.Logger) (string, map[string]string, []string, error)
StoreDataWithVersion stores data with a specified version ID It follows the same flow as StoreData but uses the provided version ID instead of generating a new one
func RetrieveData ¶
func RetrieveData(db *sql.DB, bucketID, objectID, versionID string, store sharding.ShardStore, cfg *config.Config, logger *zap.Logger) ([]byte, string, error)
RetrieveData fetches an object from a bucket and reconstructs it RetrieveData uses erasure-coding to implement fault-tolerance for lost shards During retrieval, the shards are reconstructed As long as we have enough shards (in this case at least 4 of 6 shards) the reconstruction should be successful The reconstrcuted data is decrypted, then decompressed
func Retry ¶
Retry executes the given function fn and retries it in case of an error. It uses exponential backoff for the retry intervals.
func StoreData ¶
func StoreData(db *sql.DB, data []byte, bucketID, objectID, filePath string, store sharding.ShardStore, cfg *config.Config, locations []string, logger *zap.Logger) (string, map[string]string, []string, error)
StoreData stores an object inside a bucket StoreData only works for a valid bucket, an invalid bucket would return an error The files to be stored are provided an objectID and a versionID The files to be treated are first compressed After compression, they are encrypted Successful encrypted data is then sharded and sent to their respective locations
func StoreDataWithVersion ¶
func StoreDataWithVersion(db *sql.DB, data []byte, bucketID, objectID, versionID, filePath string, store sharding.ShardStore, cfg *config.Config, locations []string, logger *zap.Logger) (string, map[string]string, []string, error)
StoreDataWithVersion is an alternative function to StoreData It takes a pre-defined object version instead of defining it locally This allows it cater for instances where a pre-defined object version has been provided
func UpdateShardLocations ¶
func UpdateShardLocations(cfg *config.Config, bucketID, objectID, versionID string, newLocations map[string]string) error
This adds property for partial override To get the new location we would rerun the lookup and updae the locations on the database
func ZipDirectory ¶
ZipDirectory compresses the specified directory into a zip file.
Types ¶
type NewStorage ¶
type NewStorage interface {
NewStoreData(db *sql.DB, data []byte, bucketID, objectID, filePath string, store sharding.ShardStore, cfg *config.Config, locations []string, logger *zap.Logger) (string, map[string]string, []string, error)
NewRetrieveData(db *sql.DB, bucketID, objectID, versionID string, store sharding.ShardStore, cfg *config.Config, logger *zap.Logger) ([]byte, string, error)
NewStoreDataWithVersion(db *sql.DB, data []byte, bucketID, objectID, versionID, filePath string, store sharding.ShardStore, cfg *config.Config, locations []string, logger *zap.Logger) (string, map[string]string, []string, error)
}
type ShardMetadata ¶
type ShardMetadata struct {
BucketID string
ObjectID string
VersionID string
ShardLocations map[string]string
}
func GetShardMetadata ¶
func GetShardMetadata(cfg *config.Config, bucketID, objectID, versionID string) (*ShardMetadata, error)
type Storage ¶
type Storage interface {
StoreData(db *sql.DB, data []byte, bucketID, objectID, filePath string, store sharding.ShardStore, cfg *config.Config, locations []string, logger *zap.Logger) (string, map[string]string, []string, error)
RetrieveData(db *sql.DB, bucketID, objectID, versionID string, store sharding.ShardStore, cfg *config.Config, logger *zap.Logger) ([]byte, string, error)
StoreDataWithVersion(db *sql.DB, data []byte, bucketID, objectID, versionID, filePath string, store sharding.ShardStore, cfg *config.Config, locations []string, logger *zap.Logger) (string, map[string]string, []string, error)
}