Documentation
¶
Overview ¶
Package memory provides an in-memory implementation of the Weave composite store. Suitable for testing and development.
Index ¶
- type Store
- func (s *Store) Close() error
- func (s *Store) CompleteDocument(ctx context.Context, docID id.DocumentID, chunkCount int) error
- func (s *Store) CountChunks(ctx context.Context, filter *chunk.CountFilter) (int64, error)
- func (s *Store) CountCollections(ctx context.Context, filter *collection.CountFilter) (int64, error)
- func (s *Store) CountDocuments(ctx context.Context, filter *document.CountFilter) (int64, error)
- func (s *Store) CountStalledUntenanted(_ context.Context, before time.Time) (int64, error)
- func (s *Store) CreateChunkBatch(ctx context.Context, chunks []*chunk.Chunk) error
- func (s *Store) CreateCollection(ctx context.Context, col *collection.Collection) error
- func (s *Store) CreateDocument(ctx context.Context, doc *document.Document) error
- func (s *Store) DeleteChunksByCollection(ctx context.Context, colID id.CollectionID) error
- func (s *Store) DeleteChunksByDocument(ctx context.Context, docID id.DocumentID) error
- func (s *Store) DeleteCollection(ctx context.Context, colID id.CollectionID) error
- func (s *Store) DeleteDocument(ctx context.Context, docID id.DocumentID) error
- func (s *Store) DeleteDocumentsByCollection(ctx context.Context, colID id.CollectionID) error
- func (s *Store) FailDocument(ctx context.Context, docID id.DocumentID, errText string, ...) error
- func (s *Store) GetChunk(ctx context.Context, chunkID id.ChunkID) (*chunk.Chunk, error)
- func (s *Store) GetCollection(ctx context.Context, colID id.CollectionID) (*collection.Collection, error)
- func (s *Store) GetCollectionByName(ctx context.Context, tenantID, name string) (*collection.Collection, error)
- func (s *Store) GetDocument(ctx context.Context, docID id.DocumentID) (*document.Document, error)
- func (s *Store) ListChunks(ctx context.Context, filter *chunk.ListFilter) ([]*chunk.Chunk, error)
- func (s *Store) ListChunksByDocument(ctx context.Context, docID id.DocumentID) ([]*chunk.Chunk, error)
- func (s *Store) ListCollections(ctx context.Context, filter *collection.ListFilter) ([]*collection.Collection, error)
- func (s *Store) ListDocuments(ctx context.Context, filter *document.ListFilter) ([]*document.Document, error)
- func (s *Store) ListStalledDocuments(_ context.Context, before time.Time, limit int) ([]*document.Document, error)
- func (s *Store) Migrate(_ context.Context) error
- func (s *Store) Ping(_ context.Context) error
- func (s *Store) ReplaceSourceDocument(ctx context.Context, doc *document.Document, chunks []*chunk.Chunk) ([]id.DocumentID, error)
- func (s *Store) TouchDocument(ctx context.Context, docID id.DocumentID, staleBefore time.Time) error
- func (s *Store) UpdateCollection(ctx context.Context, col *collection.Collection) error
- func (s *Store) UpdateDocument(ctx context.Context, doc *document.Document) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an in-memory implementation of the composite Weave store. Every data method scopes to the context tenant: another tenant's row is missing, exactly like an unknown ID.
func (*Store) CompleteDocument ¶
CompleteDocument moves a processing document to ready under the store mutex.
func (*Store) CountChunks ¶
CountChunks returns the count of chunks matching the filter.
func (*Store) CountCollections ¶
func (s *Store) CountCollections(ctx context.Context, filter *collection.CountFilter) (int64, error)
CountCollections returns the count of collections matching the filter.
func (*Store) CountDocuments ¶
CountDocuments returns the count of documents matching the filter.
func (*Store) CountStalledUntenanted ¶
CountStalledUntenanted counts the stalled rows with an empty tenant.
func (*Store) CreateChunkBatch ¶
CreateChunkBatch persists a batch of chunks. Every chunk must belong to the context tenant and to a document of that tenant, with the document's collection, and its ID must be new. Any chunk that fails refuses the whole batch before anything is written, as the SQL backends' single INSERT does.
func (*Store) CreateCollection ¶
func (s *Store) CreateCollection(ctx context.Context, col *collection.Collection) error
CreateCollection persists a new collection.
func (*Store) CreateDocument ¶
CreateDocument persists a new document. Its collection must belong to the context tenant, else ErrCollectionNotFound.
func (*Store) DeleteChunksByCollection ¶
DeleteChunksByCollection removes all chunks for a collection.
func (*Store) DeleteChunksByDocument ¶
DeleteChunksByDocument removes all chunks for a document.
func (*Store) DeleteCollection ¶
DeleteCollection removes a collection by ID with cascading deletes.
func (*Store) DeleteDocument ¶
DeleteDocument removes a document by ID with cascading chunk deletes.
func (*Store) DeleteDocumentsByCollection ¶
DeleteDocumentsByCollection removes all documents in a collection.
func (*Store) FailDocument ¶
func (s *Store) FailDocument(ctx context.Context, docID id.DocumentID, errText string, staleBefore time.Time) error
FailDocument marks a pending or processing document failed under the store mutex.
func (*Store) GetCollection ¶
func (s *Store) GetCollection(ctx context.Context, colID id.CollectionID) (*collection.Collection, error)
GetCollection retrieves a collection by ID.
func (*Store) GetCollectionByName ¶
func (s *Store) GetCollectionByName(ctx context.Context, tenantID, name string) (*collection.Collection, error)
GetCollectionByName retrieves a collection by tenant and name. tenantID must equal the context tenant.
func (*Store) GetDocument ¶
GetDocument retrieves a document by ID.
func (*Store) ListChunks ¶
ListChunks returns chunks matching the filter, ordered by document then index.
func (*Store) ListChunksByDocument ¶
func (s *Store) ListChunksByDocument(ctx context.Context, docID id.DocumentID) ([]*chunk.Chunk, error)
ListChunksByDocument returns all chunks for a document, ordered by index.
func (*Store) ListCollections ¶
func (s *Store) ListCollections(ctx context.Context, filter *collection.ListFilter) ([]*collection.Collection, error)
ListCollections returns collections matching the given filter.
func (*Store) ListDocuments ¶
func (s *Store) ListDocuments(ctx context.Context, filter *document.ListFilter) ([]*document.Document, error)
ListDocuments returns documents matching the given filter.
func (*Store) ListStalledDocuments ¶
func (s *Store) ListStalledDocuments(_ context.Context, before time.Time, limit int) ([]*document.Document, error)
ListStalledDocuments lists, across tenants, the pending, processing and superseded documents last updated before before, oldest first.
func (*Store) ReplaceSourceDocument ¶
func (s *Store) ReplaceSourceDocument(ctx context.Context, doc *document.Document, chunks []*chunk.Chunk) ([]id.DocumentID, error)
ReplaceSourceDocument supersedes the source's ready and failed documents, swaps their chunks for chunks and makes doc ready, all under the store mutex. Everything is checked before the first change, so a refused call leaves the store as it was.
func (*Store) TouchDocument ¶
func (s *Store) TouchDocument(ctx context.Context, docID id.DocumentID, staleBefore time.Time) error
TouchDocument records an ingest's heartbeat under the store mutex, so of several claims of one stalled document only the first finds it stalled.
func (*Store) UpdateCollection ¶
func (s *Store) UpdateCollection(ctx context.Context, col *collection.Collection) error
UpdateCollection persists changes to an existing collection.