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 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 CouchbaseFileBlockInfoRepository
- 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 FileBlock
- type FileBlockInfo
- type FileBlockInfoRepository
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 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 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 []FileBlock `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 CouchbaseFileBlockInfoRepository ¶
type CouchbaseFileBlockInfoRepository struct { InMemoryBucket map[string]*FileBlockInfo // contains filtered or unexported fields }
CouchbaseFileBlockInfoRepository is the couch base implementation of the FileBlockInfoRepository
func NewCouchbaseFileBlockInfoRepository ¶
func NewCouchbaseFileBlockInfoRepository() (CouchbaseFileBlockInfoRepository, error)
NewBlockedFileRepository
func (CouchbaseFileBlockInfoRepository) DeleteFileBlockInfo ¶
func (r CouchbaseFileBlockInfoRepository) DeleteFileBlockInfo(hash string) error
func (CouchbaseFileBlockInfoRepository) GetFileBlockInfo ¶
func (r CouchbaseFileBlockInfoRepository) GetFileBlockInfo(hash string) (*FileBlockInfo, error)
Get a BlockedFile from the repository
func (CouchbaseFileBlockInfoRepository) SaveFileBlockInfo ¶
func (r CouchbaseFileBlockInfoRepository) SaveFileBlockInfo(fileBlockInfo FileBlockInfo) 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 FileBlock ¶
This is a form used to link the File to the Block without needing to load the full data from the database
type FileBlockInfo ¶
type FileBlockInfo struct { Hash string `json:"hash"` UseCount int64 `json:"usecount"` Created time.Time `json:"created"` LastUsage time.Time `json:"lastUsed"` }
FileBlockInfo is used to maintain information about file blocks
type FileBlockInfoRepository ¶
type FileBlockInfoRepository interface { SaveFileBlockInfo(fileBlockInfo FileBlockInfo) error GetFileBlockInfo(hash string) (*FileBlockInfo, error) DeleteFileBlockInfo(hash string) error }
FileBlockInfoRepository inteface for FileBlockInfo storage
var FileBlockInfoStore FileBlockInfoRepository
fileBlockInfoRepository for FileBlockInfo objects