blocks

package
v0.0.0-...-fc872c1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2015 License: Apache-2.0 Imports: 16 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 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 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

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 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)

func (DiskBlockRepository) SaveBlock

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

Save persists a block into the repository

type FileBlock

type FileBlock 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 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

Jump to

Keyboard shortcuts

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