blocks

package
v0.0.0-...-d7c4e6e Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package blocks is a framework for a block based Filesystem

Current version: experimental

Index

Constants

View Source
const BlockSize100Kb int64 = 102400

100kb block size

View Source
const BlockSize1Mb int64 = 1048576

1Mb block size

View Source
const BlockSize30Kb int64 = 30720

30kb block size

View Source
const BlockSize4Mb int64 = 4194304

4Mb block size

Variables

View Source
var BlockSize int64 = BlockSize4Mb

Set default blocksize to 4Mb

View Source
var CryptoProvider crypto.CryptoProvider

CryptoProvider is the configured crypto provider to use for encrypting the data at rest

View Source
var CryptoProviderName string

CryptoProviderName is the name of the crypto provider

View Source
var StorageProviderName string

StorageProviderName is the name of the selected storage provider

View Source
var UseCompression bool = true

Compression is on by default

View Source
var UseEncryption bool = true

Use Encryption is on by default

Functions

func DeleteBlockedFile

func DeleteBlockedFile(blockFileID string) error

DeleteBlockFile - Deletes a BlockedFile and any unused FileBlocks

func SetUpRepositories

func SetUpRepositories()

Set up repositories in the init to keep connections alive

func UnblockFile

func UnblockFile(blockFileID string, targetFilePath string) error

Takes a file ID. Unblocks the files from the underlying system and then writes the file to the target file path

func UnblockFileToBuffer

func UnblockFileToBuffer(blockFileID string) (bytes.Buffer, error)

Unblock a file to a buffer stream

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

func (AzureBlockRepository) GetBlock

func (r AzureBlockRepository) GetBlock(blockHash string) ([]byte, error)

Get a block from the repository

func (AzureBlockRepository) SaveBlock

func (r AzureBlockRepository) SaveBlock(data []byte, blockHash string) error

Save persists a block into the repository

type Block

type Block struct {
	BlockPosition int    `json:"position"`
	Hash          string `json:"hash"`
}

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

func (CouchBaseBlockRepository) GetBlock

func (r CouchBaseBlockRepository) GetBlock(blockHash string) ([]byte, error)

Get a block from the repository

func (CouchBaseBlockRepository) SaveBlock

func (r CouchBaseBlockRepository) SaveBlock(bytes []byte, blockHash string) error

Save persists a block into the repository

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)

func (DiskBlockRepository) SaveBlock

func (r DiskBlockRepository) SaveBlock(bytes []byte, blockHash string) error

Save persists a block into the repository

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

func (S3BlockRepository) GetBlock

func (r S3BlockRepository) GetBlock(blockHash string) ([]byte, error)

Get a block from the repository

func (S3BlockRepository) SaveBlock

func (r S3BlockRepository) SaveBlock(data []byte, blockHash string) error

Jump to

Keyboard shortcuts

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