sqlite

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlite is a store of volumes, and their indexes, in a SQLite database, which is created when it doesn't exist, or in memory, of sqlite.Memory, such as for tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStore

type CacheStore struct {
	// contains filtered or unexported fields
}

CacheStore is the cache of a volume, in a SQLite database of its own, whose entries' content is in chunks, so it's written as it's read, and read of the chunks which are read, rather than all of it, and isn't kept in memory. An entry which is replaced, or deleted, while it's read loses its key, so it isn't found, and is deleted once it's closed.

func NewCacheStore

func NewCacheStore(ctx context.Context, path string) (*CacheStore, error)

NewCacheStore returns the cache of a volume, of the path of its database file, such as /var/cache/filer/media.sqlite, or sqlite.Memory, which is created when it doesn't exist, with its schema. The entries which were being written, or had lost their keys, when it was last closed, and those which have expired, are deleted.

func (*CacheStore) Close

func (self *CacheStore) Close() error

Close closes the database

func (*CacheStore) Delete

func (self *CacheStore) Delete(ctx context.Context, key string) error

Delete deletes the entry of the key, or those beneath it, when it ends with "/", once they aren't read

func (*CacheStore) Get

func (self *CacheStore) Get(ctx context.Context, key string) (store.CacheEntry, error)

Get returns the entry of the key, or ErrNotFound when there's none, or it expired, which is deleted. It's selected, and its reader registered, at once, so a Put, or Delete, which releases it, deletes it once it's closed.

func (*CacheStore) GetOrCreate

func (self *CacheStore) GetOrCreate(ctx context.Context, key, version string, ttl time.Duration, valuefn func(w io.Writer) (store.CacheMeta, error)) (store.CacheEntry, error)

GetOrCreate returns the entry of the key, when there's one of the version, or else, once another which creates it is done, when there's one, or else stores what valuefn writes, as it's written

func (*CacheStore) Put

func (self *CacheStore) Put(ctx context.Context, key string, ttl time.Duration, meta store.CacheMeta, r io.Reader) (store.CacheEntry, error)

Put stores the content, as it's read, in chunks, as an entry without a key, which is given the key once it's all read, in place of the entry of the key, which is deleted, once it isn't read

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a store of volumes, and their indexes, in a SQLite database

func New

func New(ctx context.Context, path string, opts ...store.Opt) (_ *Store, err error)

New returns a store of the path of its database file, such as /var/lib/filer/index.db, or sqlite.Memory, which is created when it doesn't exist, with its schema. Its queries are traced with the options' tracer, and the changes to its volumes are published to their broadcaster, once they're committed.

func (*Store) Changed

func (self *Store) Changed(ctx context.Context, volume, folder, after string, limit int) (_ []store.Seen, err error)

Changed returns, in the order of their keys, after the key, up to the limit, the files beneath the folder's key which a scan of it has seen, which aren't indexed, or whose revisions aren't those they were stored of

func (*Store) Claim

func (self *Store) Claim(ctx context.Context, volume string, kinds []store.Kind, max int, lease time.Duration) (_ []store.Work, err error)

Claim leases the work of the volume, of the kinds, which is due, and isn't leased, earliest first: a rescan, on its own, or up to max of the other kinds

func (*Store) Close

func (self *Store) Close() error

Close closes the database

func (*Store) CountChanged

func (self *Store) CountChanged(ctx context.Context, volume, folder string) (_ uint64, err error)

CountChanged returns how many files Changed returns, of every page

func (*Store) CountObjects

func (self *Store) CountObjects(ctx context.Context, volume string, req store.ListRequest) (_ uint64, err error)

CountObjects returns how many objects a listing has, of every page, without the key it starts after, or its limit

func (*Store) CreateVolume

func (self *Store) CreateVolume(ctx context.Context, volume filer.VolumeMeta) (_ *filer.Volume, err error)

CreateVolume stores a new volume, and returns it, or returns ErrConflict when a volume of its name is stored

func (*Store) DeleteMetadata

func (self *Store) DeleteMetadata(ctx context.Context, volume, source string) (err error)

DeleteMetadata removes the metadata of the source, a task's kind, of every object of the volume, and its task's work, and the revisions it was done of

func (*Store) DeleteObject

func (self *Store) DeleteObject(ctx context.Context, volume, key string) (err error)

DeleteObject removes the object of the volume of the key, and, of a folder's, every object beneath it, with their metadata, which isn't an error when there's none

func (*Store) DeleteVolume

func (self *Store) DeleteVolume(ctx context.Context, name string) (err error)

DeleteVolume removes a volume, with its index, or returns ErrNotFound

func (*Store) Done

func (self *Store) Done(ctx context.Context, volume string, work ...store.Work) (err error)

Done removes the work, which is claimed, unless it's pushed again since, when it's kept, so it's claimed again

func (*Store) Failed

func (self *Store) Failed(ctx context.Context, volume string, work store.Work, cause error, retry time.Duration) (err error)

Failed counts an attempt of the work, which is claimed, with why it failed, and makes it due again after the retry. Work which isn't claimed, as it's pushed again since, isn't counted.

func (*Store) GetObject

func (self *Store) GetObject(ctx context.Context, volume, key string) (_ *filer.Object, err error)

GetObject returns the object of the volume of the key, with its metadata, or ErrNotFound

func (*Store) GetVolume

func (self *Store) GetVolume(ctx context.Context, name string) (_ *filer.Volume, err error)

GetVolume returns a volume, or ErrNotFound

func (*Store) Kinds

func (self *Store) Kinds(ctx context.Context, volume string) (_ map[string]uint64, err error)

Kinds returns how many objects, without folders, of the volume are of each kind, of their metadata, or else their media type, or "", of none

func (*Store) ListObjects

func (self *Store) ListObjects(ctx context.Context, volume string, req store.ListRequest) (_ []*filer.Object, err error)

ListObjects returns, in the order of their keys, up to the request's limit of the objects of a folder, or every object beneath it when it's recursive, after the key it starts after, without the folder

func (*Store) ListVolumes

func (self *Store) ListVolumes(ctx context.Context) (_ []*filer.Volume, err error)

ListVolumes returns the volumes, in the order of their names

func (*Store) Pending

func (self *Store) Pending(ctx context.Context, volume, key string) (_ bool, err error)

Pending returns true when the key has work queued, or claimed, which would change its index: an index of it, or a rescan of it, or of a folder above it

func (*Store) PendingBeneath

func (self *Store) PendingBeneath(ctx context.Context, volume, folder string) (_ bool, err error)

PendingBeneath returns true when the folder's key has work queued, or claimed, which would change its listing: an index of it, or a rescan of it, or of a folder above it, or an index, or a rescan, of a key beneath it

func (*Store) Push

func (self *Store) Push(ctx context.Context, volume string, work ...store.Work) (err error)

Push queues work of the volume, coalesced, in one transaction, or returns ErrNotFound when the volume isn't stored

func (*Store) PushStale

func (self *Store) PushStale(ctx context.Context, volume, folder string, kind store.Kind) (err error)

PushStale queues the work of a task of the files beneath the folder's key whose listings' revisions aren't those the task was last done of, or returns ErrNotFound when the volume isn't stored

func (*Store) PutObject

func (self *Store) PutObject(ctx context.Context, volume string, objects ...*filer.Object) (err error)

PutObject stores the objects of the volume, replacing those of their keys, and their metadata, in one transaction, or returns ErrNotFound when the volume isn't stored

func (*Store) Revisions

func (self *Store) Revisions(ctx context.Context, volume, folder string, recursive bool) (_ map[string]string, err error)

Revisions returns, by their keys, the revisions of the files of a folder's key, or of every file beneath it, when it's recursive

func (*Store) Search

func (self *Store) Search(ctx context.Context, req filer.SearchRequest) (_ *filer.SearchResponse, err error)

Search returns the objects of the query's volumes, or of every volume, without any, which match the request's query, best first, with their volumes' names, of its page, and how many match, of every page, which is none of a query without terms

func (*Store) Seen

func (self *Store) Seen(ctx context.Context, volume string, seen map[string]string) (err error)

Seen records the keys which a scan has seen, with the revisions of their listings, in one transaction, or returns ErrNotFound when the volume isn't stored

func (*Store) SetMetadata

func (self *Store) SetMetadata(ctx context.Context, volume, key, source string, of *filer.ObjectAttr, found filer.TaskMeta) (err error)

SetMetadata replaces the metadata of the object of the volume of the key, of the source, a task's kind, in one transaction, or returns ErrNotFound when the object isn't indexed, or ErrPreconditionFailed when it isn't of the attributes, which the task read, any more

func (*Store) SetRevisions

func (self *Store) SetRevisions(ctx context.Context, volume string, revisions map[string]string) (err error)

SetRevisions stores the revisions of the files, by their keys, in one transaction, or returns ErrNotFound when the volume isn't stored

func (*Store) SetState

func (self *Store) SetState(ctx context.Context, volume string, state filer.IndexState) (err error)

SetState stores the state of the volume's index, or returns ErrNotFound when the volume isn't stored

func (*Store) State

func (self *Store) State(ctx context.Context, volume string) (_ filer.IndexState, err error)

State returns the state of the volume's index, which is StatusNone when it's never been indexed, or the volume isn't stored

func (*Store) Sweep

func (self *Store) Sweep(ctx context.Context, volume, folder string) (err error)

Sweep removes the objects beneath the folder's key, with their metadata, which a scan of it hasn't seen

func (*Store) Tasks

func (self *Store) Tasks(ctx context.Context, volume string, kind store.Kind) (_ filer.TaskState, err error)

Tasks returns the state of the work of a task of the volume's files

func (*Store) Unsee

func (self *Store) Unsee(ctx context.Context, volume, folder string) (err error)

Unsee forgets what a scan has seen beneath the folder's key

func (*Store) UpdateVolume

func (self *Store) UpdateVolume(ctx context.Context, volume filer.VolumeMeta) (_ *filer.Volume, err error)

UpdateVolume replaces a stored volume's URL, and whether it's enabled, keeping its index, and returns it, or returns ErrNotFound when it isn't stored. It's only modified, and published, when they change.

Directories

Path Synopsis
Package schema is the schema of the SQLite store: its tables, its queries, and the types which are read from, and written to, them
Package schema is the schema of the SQLite store: its tables, its queries, and the types which are read from, and written to, them

Jump to

Keyboard shortcuts

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