Documentation ¶
Index ¶
- Constants
- func GetDBName() string
- func InitFilestore() error
- func MakeDB(ctx context.Context) (*sqlx.DB, error)
- 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)
- type CacheEntry
- type DataCacheEntry
- type FileData
- type FileMeta
- type FileOptsType
- type FileStore
- func (s *FileStore) AppendData(ctx context.Context, zoneId string, name string, data []byte) error
- func (s *FileStore) AppendIJson(ctx context.Context, zoneId string, name string, command map[string]any) error
- func (s *FileStore) CompactIJson(ctx context.Context, zoneId string, name string) error
- func (s *FileStore) DeleteFile(ctx context.Context, zoneId string, name string) error
- func (s *FileStore) DeleteZone(ctx context.Context, zoneId string) error
- func (s *FileStore) FlushCache(ctx context.Context) (stats FlushStats, rtnErr error)
- func (s *FileStore) GetAllZoneIds(ctx context.Context) ([]string, error)
- func (s *FileStore) ListFiles(ctx context.Context, zoneId string) ([]*WaveFile, error)
- func (s *FileStore) MakeFile(ctx context.Context, zoneId string, name string, meta FileMeta, ...) error
- func (s *FileStore) ReadAt(ctx context.Context, zoneId string, name string, offset int64, size int64) (rtnOffset int64, rtnData []byte, rtnErr error)
- func (s *FileStore) ReadFile(ctx context.Context, zoneId string, name string) (rtnOffset int64, rtnData []byte, rtnErr error)
- func (s *FileStore) Stat(ctx context.Context, zoneId string, name string) (*WaveFile, error)
- func (s *FileStore) WriteAt(ctx context.Context, zoneId string, name string, offset int64, data []byte) error
- func (s *FileStore) WriteFile(ctx context.Context, zoneId string, name string, data []byte) error
- func (s *FileStore) WriteMeta(ctx context.Context, zoneId string, name string, meta FileMeta, merge bool) error
- type FlushStats
- type TxWrap
- type WaveFile
Constants ¶
View Source
const ( // ijson meta keys IJsonNumCommands = "ijson:numcmds" IJsonIncrementalBytes = "ijson:incbytes" )
View Source
const ( IJsonHighCommands = 100 IJsonHighRatio = 3 IJsonLowRatio = 1 IJsonLowCommands = 10 )
View Source
const DefaultFlushTime = 5 * time.Second
View Source
const DefaultPartDataSize = 64 * 1024
View Source
const FilestoreDBName = "filestore.db"
View Source
const NoPartIdx = -1
Variables ¶
This section is empty.
Functions ¶
func InitFilestore ¶
func InitFilestore() error
Types ¶
type CacheEntry ¶
type CacheEntry struct { PinCount int // this is synchronzed with the FileStore lock (not the entry lock) Lock *sync.Mutex ZoneId string Name string File *WaveFile DataEntries map[int]*DataCacheEntry FlushErrors int }
if File or DataEntries are not nil then they are dirty (need to be flushed to disk)
type DataCacheEntry ¶
type FileData ¶
type FileOptsType ¶
type FileStore ¶
type FileStore struct { Lock *sync.Mutex Cache map[cacheKey]*CacheEntry IsFlushing bool }
func (*FileStore) AppendData ¶
func (*FileStore) AppendIJson ¶
func (*FileStore) CompactIJson ¶
func (*FileStore) DeleteFile ¶
func (*FileStore) DeleteZone ¶
func (*FileStore) FlushCache ¶
func (s *FileStore) FlushCache(ctx context.Context) (stats FlushStats, rtnErr error)
func (*FileStore) GetAllZoneIds ¶
func (*FileStore) MakeFile ¶
func (s *FileStore) MakeFile(ctx context.Context, zoneId string, name string, meta FileMeta, opts FileOptsType) error
synchronous (does not interact with the cache)
func (*FileStore) ReadAt ¶
func (s *FileStore) ReadAt(ctx context.Context, zoneId string, name string, offset int64, size int64) (rtnOffset int64, rtnData []byte, rtnErr error)
returns (offset, data, error) we return the offset because the offset may have been adjusted if the size was too big (for circular files)
func (*FileStore) ReadFile ¶
func (s *FileStore) ReadFile(ctx context.Context, zoneId string, name string) (rtnOffset int64, rtnData []byte, rtnErr error)
returns (offset, data, error)
type FlushStats ¶
type WaveFile ¶
type WaveFile struct { // these fields are static (not updated) ZoneId string `json:"zoneid"` Name string `json:"name"` Opts FileOptsType `json:"opts"` CreatedTs int64 `json:"createdts"` // these fields are mutable Size int64 `json:"size"` ModTs int64 `json:"modts"` Meta FileMeta `json:"meta"` // only top-level keys can be updated (lower levels are immutable) }
func (WaveFile) DataLength ¶
for regular files this is just Size for circular files this is min(Size, MaxSize)
func (WaveFile) DataStartIdx ¶
for regular files this is just 0 for circular files this is the index of the first byte of data we have
Click to show internal directories.
Click to hide internal directories.