Documentation ¶
Overview ¶
Package blocks is a framework for a block based Filesystem
Current version: experimental
Index ¶
- Constants
- Variables
- func DeleteBlockedFile(blockFileID string) error
- func SetUpRepositories()
- func UnblockFile(blockFileID string, targetFilePath string) error
- func UnblockFileToBuffer(blockFileID string) (bytes.Buffer, error)
- type AzureBlockRepository
- type Block
- type BlockInfo
- type BlockInfoRepository
- type BlockRepository
- type BlockedFile
- type BlockedFileRepository
- type CouchBaseBlockRepository
- func (r CouchBaseBlockRepository) CheckBlockExists(blockHash string) (bool, error)
- func (r CouchBaseBlockRepository) DeleteBlock(blockHash string) error
- func (r CouchBaseBlockRepository) GetBlock(blockHash string) ([]byte, error)
- func (r CouchBaseBlockRepository) SaveBlock(bytes []byte, blockHash string) error
- type CouchbaseBlockInfoRepository
- type DiskBlockRepository
- func (r DiskBlockRepository) CheckBlockExists(blockHash string) (bool, error)
- func (r DiskBlockRepository) DeleteBlock(blockHash string) error
- func (r DiskBlockRepository) GetBlock(blockHash string) ([]byte, error)
- func (r DiskBlockRepository) GetDataDirectory(hash string) (string, error)
- func (r DiskBlockRepository) SaveBlock(bytes []byte, blockHash string) error
- type S3BlockRepository
Constants ¶
const BlockSize100Kb int64 = 102400
100kb block size
const BlockSize1Mb int64 = 1048576
1Mb block size
const BlockSize30Kb int64 = 30720
30kb block size
const BlockSize4Mb int64 = 4194304
4Mb block size
Variables ¶
var BlockSize int64 = BlockSize4Mb
Set default blocksize to 4Mb
var CryptoProvider crypto.CryptoProvider
CryptoProvider is the configured crypto provider to use for encrypting the data at rest
var CryptoProviderName string
CryptoProviderName is the name of the crypto provider
var StorageProviderName string
StorageProviderName is the name of the selected storage provider
var UseCompression bool = true
Compression is on by default
var UseEncryption bool = true
Use Encryption is on by default
Functions ¶
func DeleteBlockedFile ¶
DeleteBlockFile - Deletes a BlockedFile and any unused FileBlocks
func SetUpRepositories ¶
func SetUpRepositories()
Set up repositories in the init to keep connections alive
func UnblockFile ¶
Takes a file ID. Unblocks the files from the underlying system and then writes the file to the target file path
Types ¶
type AzureBlockRepository ¶
type AzureBlockRepository struct {
// contains filtered or unexported fields
}
func NewAzureBlockRepository ¶
func NewAzureBlockRepository() (AzureBlockRepository, error)
NewAzureBlockRepository
func (AzureBlockRepository) CheckBlockExists ¶
func (r AzureBlockRepository) CheckBlockExists(blockHash string) (bool, error)
Check to see if a block exists
func (AzureBlockRepository) DeleteBlock ¶
func (r AzureBlockRepository) DeleteBlock(blockHash string) error
DeleteBlock - Deletes a block of data
type Block ¶
This is a form used to link the File to the Block without needing to load the full data from the database
type BlockInfo ¶
type BlockInfo struct { Hash string `json:"hash"` StoreID string `json:"storeid"` UseCount int64 `json:"usecount"` Created time.Time `json:"created"` LastUsage time.Time `json:"lastUsed"` }
BlockInfo is used to maintain information about file blocks
type BlockInfoRepository ¶
type BlockInfoRepository interface { SaveBlockInfo(blockInfo BlockInfo) error GetBlockInfo(hash string) (*BlockInfo, error) DeleteBlockInfo(hash string) error }
FileBlockInfoRepository inteface for FileBlockInfo storage
var BlockInfoStore BlockInfoRepository
fileBlockInfoRepository for FileBlockInfo objects
type BlockRepository ¶
type BlockRepository interface { SaveBlock(bytes []byte, hash string) error GetBlock(blockHash string) ([]byte, error) CheckBlockExists(blockHash string) (bool, error) DeleteBlock(blockHash string) error }
BlockRepository is the interface for saving blocks to disk
var BlockStore BlockRepository
Repository for blocks
type BlockedFile ¶
type BlockedFile struct { ID string `json:"id"` FileHash string `json:"fileHash"` Length int64 `json:"length"` BlockList []Block `json:"blocks"` }
File is a representation of a blocks together to form a file
func BlockBuffer ¶
func BlockBuffer(source io.Reader) (BlockedFile, error)
Block a source into a file
func BlockFile ¶
func BlockFile(sourceFilepath string) (BlockedFile, error)
Create a new file. Expects a filename. Returns any error or the created BlockedFile
func CopyBlockedFile ¶
func CopyBlockedFile(blockFileID string) (BlockedFile, error)
CopyBlockedFile - Copy a blocked file and return the new BlockedFile
type BlockedFileRepository ¶
type BlockedFileRepository struct { InMemoryBucket map[string]*BlockedFile // contains filtered or unexported fields }
BlockedFileRepository : a Couchbase Server repository
var BlockedFileStore BlockedFileRepository
Repository for blockedFiles
func NewBlockedFileRepository ¶
func NewBlockedFileRepository() (BlockedFileRepository, error)
NewBlockedFileRepository
func (BlockedFileRepository) DeleteBlockedFile ¶
func (r BlockedFileRepository) DeleteBlockedFile(blockfileid string) error
DeleteBlockedFile - Delete a blocked file
func (BlockedFileRepository) GetBlockedFile ¶
func (r BlockedFileRepository) GetBlockedFile(blockfileid string) (*BlockedFile, error)
Get a BlockedFile from the repository
func (BlockedFileRepository) SaveBlockedFile ¶
func (r BlockedFileRepository) SaveBlockedFile(blockedFile BlockedFile) error
Save persists a BlockedFile into the repository
type CouchBaseBlockRepository ¶
type CouchBaseBlockRepository struct {
// contains filtered or unexported fields
}
func NewCouchBaseBlockRepository ¶
func NewCouchBaseBlockRepository() (CouchBaseBlockRepository, error)
NewCouchBaseBlockRepository
func (CouchBaseBlockRepository) CheckBlockExists ¶
func (r CouchBaseBlockRepository) CheckBlockExists(blockHash string) (bool, error)
Check to see if a block exists
func (CouchBaseBlockRepository) DeleteBlock ¶
func (r CouchBaseBlockRepository) DeleteBlock(blockHash string) error
DeleteBlock - Deletes a block of data
type CouchbaseBlockInfoRepository ¶
type CouchbaseBlockInfoRepository struct { InMemoryBucket map[string]*BlockInfo // contains filtered or unexported fields }
CouchbaseFileBlockInfoRepository is the couch base implementation of the FileBlockInfoRepository
func NewCouchbaseBlockInfoRepository ¶
func NewCouchbaseBlockInfoRepository() (CouchbaseBlockInfoRepository, error)
NewBlockedFileRepository
func (CouchbaseBlockInfoRepository) DeleteBlockInfo ¶
func (r CouchbaseBlockInfoRepository) DeleteBlockInfo(hash string) error
func (CouchbaseBlockInfoRepository) GetBlockInfo ¶
func (r CouchbaseBlockInfoRepository) GetBlockInfo(hash string) (*BlockInfo, error)
Get a BlockedFile from the repository
func (CouchbaseBlockInfoRepository) SaveBlockInfo ¶
func (r CouchbaseBlockInfoRepository) SaveBlockInfo(blockInfo BlockInfo) error
Save persists a BlockedFile into the repository
type DiskBlockRepository ¶
type DiskBlockRepository struct {
// contains filtered or unexported fields
}
DiskBlockRepository : Saves blocks to disk
func NewDiskBlockRepository ¶
func NewDiskBlockRepository() (DiskBlockRepository, error)
NewBlockRepository
func (DiskBlockRepository) CheckBlockExists ¶
func (r DiskBlockRepository) CheckBlockExists(blockHash string) (bool, error)
Check to see if a block exists
func (DiskBlockRepository) DeleteBlock ¶
func (r DiskBlockRepository) DeleteBlock(blockHash string) error
DeleteBlock - Deletes a block of data
func (DiskBlockRepository) GetBlock ¶
func (r DiskBlockRepository) GetBlock(blockHash string) ([]byte, error)
Get a block from the repository
func (DiskBlockRepository) GetDataDirectory ¶
func (r DiskBlockRepository) GetDataDirectory(hash string) (string, error)
type S3BlockRepository ¶
type S3BlockRepository struct {
// contains filtered or unexported fields
}
func NewS3BlockRepository ¶
func NewS3BlockRepository() (S3BlockRepository, error)
NewAzureBlockRepository
func (S3BlockRepository) CheckBlockExists ¶
func (r S3BlockRepository) CheckBlockExists(blockHash string) (bool, error)
Check to see if a block exists
func (S3BlockRepository) DeleteBlock ¶
func (r S3BlockRepository) DeleteBlock(blockHash string) error
DeleteBlock - Deletes a block of data