Documentation ¶
Overview ¶
Package memdb implements kcd.ReadWriter with an in-memory representation, suitable for testing or ephemeral service-based collections.
Index ¶
- Constants
- type DB
- func (db *DB) DeleteFile(_ context.Context, fileDigest string) error
- func (db *DB) DeleteRevision(_ context.Context, revision, corpus string) error
- func (db *DB) DeleteUnit(_ context.Context, unitDigest string) error
- func (db DB) Files(_ context.Context, fileDigests []string, f func(string, []byte) error) error
- func (db DB) FilesExist(_ context.Context, fileDigests []string, f func(string) error) error
- func (db DB) Find(_ context.Context, filter *kcd.FindFilter, f func(string) error) error
- func (db DB) Revisions(_ context.Context, want *kcd.RevisionsFilter, f func(kcd.Revision) error) error
- func (db *DB) SetIndex(digest, key, value string)
- func (db DB) Units(_ context.Context, unitDigests []string, ...) error
- func (db *DB) WriteFile(_ context.Context, r io.Reader) (string, error)
- func (db *DB) WriteRevision(_ context.Context, rev kcd.Revision, replace bool) error
- func (db *DB) WriteUnit(_ context.Context, rev kcd.Revision, formatKey string, unit kcd.Unit) (string, error)
- type Index
- type Unit
Constants ¶
const ( RevisionKey = "revision" CorpusKey = "corpus" UnitCorpusKey = "unit_corpus" OutputKey = "output" LanguageKey = "language" TargetKey = "target" SourceKey = "source" )
String tags for index keys matching the fields of a kcd.FindFilter.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct { Rev []kcd.Revision Unit map[string]Unit // :: unit digest → compilation record File map[string]string // :: file digest → file content Index map[string]Index // :: unit digest → index entries }
DB implements kcd.Reader, and *DB implements kcd.ReadWriter and kcd.Deleter. Records are stored in exported fields, to assist in testing. The zero value is ready for use as an empty database.
func (*DB) DeleteFile ¶
DeleteFile implements a method of kcd.Deleter.
func (*DB) DeleteRevision ¶
DeleteRevision implements a method of kcd.Deleter.
func (*DB) DeleteUnit ¶
DeleteUnit implements a method of kcd.Deleter.
func (DB) FilesExist ¶
FilesExist implements a method of kcd.Reader.
func (DB) Revisions ¶
func (db DB) Revisions(_ context.Context, want *kcd.RevisionsFilter, f func(kcd.Revision) error) error
Revisions implements a method of kcd.Reader.
func (DB) Units ¶
func (db DB) Units(_ context.Context, unitDigests []string, f func(digest, key string, data []byte) error) error
Units implements a method of kcd.Reader.
func (*DB) WriteRevision ¶
WriteRevision implements a method of kcd.Writer.