github.com/safing/portbase@v0.19.5/database/storage/interface.go (about) 1 package storage 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/safing/portbase/database/iterator" 8 "github.com/safing/portbase/database/query" 9 "github.com/safing/portbase/database/record" 10 ) 11 12 // Interface defines the database storage API. 13 type Interface interface { 14 // Primary Interface 15 Get(key string) (record.Record, error) 16 Put(m record.Record) (record.Record, error) 17 Delete(key string) error 18 Query(q *query.Query, local, internal bool) (*iterator.Iterator, error) 19 20 // Information and Control 21 ReadOnly() bool 22 Injected() bool 23 Shutdown() error 24 25 // Mandatory Record Maintenance 26 MaintainRecordStates(ctx context.Context, purgeDeletedBefore time.Time, shadowDelete bool) error 27 } 28 29 // MetaHandler defines the database storage API for backends that support optimized fetching of only the metadata. 30 type MetaHandler interface { 31 GetMeta(key string) (*record.Meta, error) 32 } 33 34 // Maintainer defines the database storage API for backends that require regular maintenance. 35 type Maintainer interface { 36 Maintain(ctx context.Context) error 37 MaintainThorough(ctx context.Context) error 38 } 39 40 // Batcher defines the database storage API for backends that support batch operations. 41 type Batcher interface { 42 PutMany(shadowDelete bool) (batch chan<- record.Record, errs <-chan error) 43 } 44 45 // Purger defines the database storage API for backends that support the purge operation. 46 type Purger interface { 47 Purge(ctx context.Context, q *query.Query, local, internal, shadowDelete bool) (int, error) 48 }