Documentation ¶
Index ¶
- Constants
- func AppendData(ctx context.Context, blockId string, name string, p []byte) (int, error)
- func CloseDB()
- func DeleteBlock(ctx context.Context, blockId string) error
- func DeleteBlockFromDB(ctx context.Context, blockId string) error
- func DeleteCacheEntry(ctx context.Context, blockId string, name string)
- func DeleteFile(ctx context.Context, blockId string, name string) error
- func DeleteFileFromDB(ctx context.Context, blockId string, name string) error
- func FlushCache(ctx context.Context) error
- func GetAllBlockIds(ctx context.Context) []string
- func GetAllBlockIdsInDB(ctx context.Context) ([]string, error)
- func GetAllBlockSizes(dataBlocks []*CacheBlock) (int, int)
- func GetCacheFromDB(ctx context.Context, blockId string, name string, off int64, length int64, ...) (*[]byte, error)
- func GetCacheId(blockId string, name string) string
- func GetClockString(t time.Time) string
- func GetDB(ctx context.Context) (*sqlx.DB, error)
- func GetDBName() string
- func GetMigrateVersion(m *migrate.Migrate) (uint, bool, error)
- func GetValuesFromCacheId(cacheId string) (blockId string, name string)
- func InsertFileIntoDB(ctx context.Context, fileInfo FileInfo) error
- func MakeBlockstoreMigrate() (*migrate.Migrate, error)
- func MakeFile(ctx context.Context, blockId string, name string, meta FileMeta, ...) error
- func MigrateBlockstore() error
- func ReadAt(ctx context.Context, blockId string, name string, p *[]byte, off int64) (int, error)
- func ReadFromCacheBlock(ctx context.Context, blockId string, name string, block *CacheBlock, p *[]byte, ...) (int, error)
- func SetCacheEntry(ctx context.Context, cacheId string, cacheEntry *CacheEntry)
- func SetFlushTimeout(newTimeout time.Duration)
- func StartFlushTimer(ctx context.Context)
- func WithTx(ctx context.Context, fn func(tx *TxWrap) error) error
- func WithTxRtn[RT any](ctx context.Context, fn func(tx *TxWrap) (RT, error)) (RT, error)
- func WriteAt(ctx context.Context, blockId string, name string, p []byte, off int64) (int, error)
- func WriteAtHelper(ctx context.Context, blockId string, name string, p []byte, off int64, ...) (int, error)
- func WriteDataBlockToDB(ctx context.Context, blockId string, name string, index int, data []byte) error
- func WriteFile(ctx context.Context, blockId string, name string, meta FileMeta, ...) (int, error)
- func WriteFileToDB(ctx context.Context, fileInfo FileInfo) error
- func WriteMeta(ctx context.Context, blockId string, name string, meta FileMeta) error
- func WriteToCacheBlockNum(ctx context.Context, blockId string, name string, p []byte, pos int, ...) (int64, int, error)
- func WriteToCacheBuf(buf *[]byte, p []byte, pos int, length int, maxWrite int64) (int, error)
- type BlockStore
- type CacheBlock
- type CacheEntry
- type FileInfo
- func DeepCopyFileInfo(fInfo *FileInfo) *FileInfo
- func GetAllFilesInDB(ctx context.Context) ([]*FileInfo, error)
- func GetAllFilesInDBForBlockId(ctx context.Context, blockId string) ([]*FileInfo, error)
- func GetFileInfo(ctx context.Context, blockId string, name string) (*FileInfo, error)
- func ListAllFiles(ctx context.Context) []*FileInfo
- func ListFiles(ctx context.Context, blockId string) []*FileInfo
- func Stat(ctx context.Context, blockId string, name string) (*FileInfo, error)
- type FileMeta
- type FileOptsType
- type SingleConnDBGetter
- type TxWrap
Constants ¶
View Source
const DBFileName = "blockstore.db"
View Source
const DefaultFlushTimeout = 1 * time.Second
View Source
const MaxBlockSize = int64(128 * UnitsKB)
View Source
const MaxSizeError = "MaxSizeError"
View Source
const UnitsGB = 1024 * UnitsMB
View Source
const UnitsKB = 1024 * 1024
View Source
const UnitsMB = 1024 * UnitsKB
Variables ¶
This section is empty.
Functions ¶
func AppendData ¶
func DeleteFileFromDB ¶
func FlushCache ¶
func GetAllBlockIds ¶
func GetAllBlockSizes ¶
func GetAllBlockSizes(dataBlocks []*CacheBlock) (int, int)
func GetCacheFromDB ¶
func GetCacheId ¶
func GetClockString ¶
func GetMigrateVersion ¶
func GetValuesFromCacheId ¶
func MakeBlockstoreMigrate ¶
func MakeBlockstoreMigrate() (*migrate.Migrate, error)
func MigrateBlockstore ¶
func MigrateBlockstore() error
func ReadFromCacheBlock ¶
func SetCacheEntry ¶
func SetCacheEntry(ctx context.Context, cacheId string, cacheEntry *CacheEntry)
func SetFlushTimeout ¶
func StartFlushTimer ¶
func WriteAtHelper ¶
func WriteDataBlockToDB ¶
func WriteToCacheBlockNum ¶
Types ¶
type BlockStore ¶
type BlockStore interface { MakeFile(ctx context.Context, blockId string, name string, meta FileMeta, opts FileOptsType) error WriteFile(ctx context.Context, blockId string, name string, meta FileMeta, opts FileOptsType, data []byte) (int, error) AppendData(ctx context.Context, blockId string, name string, p []byte) (int, error) WriteAt(ctx context.Context, blockId string, name string, p []byte, off int64) (int, error) ReadAt(ctx context.Context, blockId string, name string, p *[]byte, off int64) (int, error) Stat(ctx context.Context, blockId string, name string) (FileInfo, error) CollapseIJson(ctx context.Context, blockId string, name string) error WriteMeta(ctx context.Context, blockId string, name string, meta FileMeta) error DeleteFile(ctx context.Context, blockId string, name string) error DeleteBlock(ctx context.Context, blockId string) error ListFiles(ctx context.Context, blockId string) []*FileInfo FlushCache(ctx context.Context) error GetAllBlockIds(ctx context.Context) []string }
add ctx context.Context to all these methods
type CacheBlock ¶
type CacheBlock struct {
// contains filtered or unexported fields
}
func GetCacheBlock ¶
type CacheEntry ¶
type CacheEntry struct { Lock *sync.Mutex CacheTs int64 Info *FileInfo DataBlocks []*CacheBlock Refs int64 }
func GetCacheEntry ¶
func GetCacheEntryOrPopulate ¶
func MakeCacheEntry ¶
func MakeCacheEntry(info *FileInfo) *CacheEntry
func (*CacheEntry) DecRefs ¶
func (c *CacheEntry) DecRefs()
func (*CacheEntry) IncRefs ¶
func (c *CacheEntry) IncRefs()
type FileInfo ¶
type FileInfo struct { BlockId string Name string Size int64 CreatedTs int64 ModTs int64 Opts FileOptsType Meta FileMeta }
func DeepCopyFileInfo ¶
func GetFileInfo ¶
func ListAllFiles ¶
type FileOptsType ¶
type SingleConnDBGetter ¶
func (*SingleConnDBGetter) ReleaseDB ¶
func (dbg *SingleConnDBGetter) ReleaseDB(db *sqlx.DB)
Click to show internal directories.
Click to hide internal directories.