Documentation
¶
Index ¶
- Variables
- func BasicTestSuite(provider Provider)
- func BucketTestSuite(provider Provider)
- func Count(ctx context.Context, bucket Bucket) (int64, error)
- func ForEach(ctx context.Context, bucket Bucket, fn func(item Item) error) error
- func IteratorTestSuite(provider Provider)
- func NewJsonHandlerUpdateTx(db DB, jsonHandler JsonHandlerTx) libhttp.WithError
- func NewJsonHandlerViewTx(db DB, jsonHandler JsonHandlerTx) libhttp.WithError
- func NewResetBucketHandler(db DB, cancel context.CancelFunc) http.Handler
- func NewResetHandler(db DB, cancel context.CancelFunc) http.Handler
- func RelationStoreTestSuite(provider Provider)
- type Bucket
- type BucketName
- type BucketNames
- type DB
- type Item
- type Iterator
- type JsonHandlerTx
- type JsonHandlerTxFunc
- type Key
- type Provider
- type ProviderFunc
- type RelationStore
- type RelationStoreString
- type RelationStoreTx
- type RelationStoreTxString
- type Store
- type StoreAdder
- type StoreAdderTx
- type StoreExists
- type StoreExistsTx
- type StoreGetter
- type StoreGetterTx
- type StoreMapper
- type StoreMapperTx
- type StoreRemover
- type StoreRemoverTx
- type StoreStream
- type StoreStreamTx
- type StoreTx
- type Tx
Constants ¶
This section is empty.
Variables ¶
View Source
var BucketAlreadyExistsError = errors.New("bucket already exists")
View Source
var BucketNotFoundError = errors.New("bucket not found")
View Source
var KeyNotFoundError = errors.New("key not found")
KeyNotFoundError is currently not return, but can be used as common error
View Source
var TransactionAlreadyOpenError = errors.New("transaction already open")
Functions ¶
func BasicTestSuite ¶
func BasicTestSuite(provider Provider)
func BucketTestSuite ¶
func BucketTestSuite(provider Provider)
func IteratorTestSuite ¶
func IteratorTestSuite(provider Provider)
func NewJsonHandlerUpdateTx ¶
func NewJsonHandlerUpdateTx(db DB, jsonHandler JsonHandlerTx) libhttp.WithError
func NewJsonHandlerViewTx ¶
func NewJsonHandlerViewTx(db DB, jsonHandler JsonHandlerTx) libhttp.WithError
func NewResetBucketHandler ¶
func NewResetBucketHandler(db DB, cancel context.CancelFunc) http.Handler
NewResetBucketHandler returns a http.Handler that allow delete a bucket
func NewResetHandler ¶
func NewResetHandler(db DB, cancel context.CancelFunc) http.Handler
NewResetHandler returns a http.Handler that allow delete the complete database
func RelationStoreTestSuite ¶
func RelationStoreTestSuite(provider Provider)
Types ¶
type BucketName ¶
type BucketName []byte
func BucketFromStrings ¶
func BucketFromStrings(values ...string) BucketName
func NewBucketName ¶
func NewBucketName(name string) BucketName
func (BucketName) Bytes ¶
func (b BucketName) Bytes() []byte
func (BucketName) Equal ¶
func (b BucketName) Equal(value BucketName) bool
func (BucketName) String ¶
func (b BucketName) String() string
type BucketNames ¶
type BucketNames []BucketName
func (BucketNames) Contains ¶
func (t BucketNames) Contains(value BucketName) bool
type DB ¶
type DB interface {
// Update opens a write transaction
Update(ctx context.Context, fn func(ctx context.Context, tx Tx) error) error
// View opens a read only transaction
View(ctx context.Context, fn func(ctx context.Context, tx Tx) error) error
// Sync database to disk
Sync() error
// Close database
Close() error
// Remove database files from disk
Remove() error
}
type Item ¶
func NewByteItem ¶
type JsonHandlerTx ¶
type JsonHandlerTxFunc ¶
type ProviderFunc ¶
type RelationStore ¶
type RelationStore[ID ~[]byte | ~string, RelatedID ~[]byte | ~string] interface { // Add the given relationIDs to ID Add(ctx context.Context, id ID, relatedIds []RelatedID) error // Replace all relations of id with the given Replace(ctx context.Context, id ID, relatedIds []RelatedID) error // Remove all relation from ID to the given Remove(ctx context.Context, id ID, relatedIds []RelatedID) error // Delete ID and all relations Delete(ctx context.Context, id ID) error // RelatedIDs return all relation of ID RelatedIDs(ctx context.Context, id ID) ([]RelatedID, error) // IDs return all ids of RelatedID IDs(ctx context.Context, relatedId RelatedID) ([]ID, error) // StreamIDs return all existings IDs StreamIDs(ctx context.Context, ch chan<- ID) error // StreamRelatedIDs return all existings relationIDs StreamRelatedIDs(ctx context.Context, ch chan<- RelatedID) error }
RelationStore implement a forward and backword id lookup for a 1:N relation.
func NewRelationStore ¶
type RelationStoreString ¶
type RelationStoreString RelationStore[string, string]
type RelationStoreTx ¶
type RelationStoreTx[ID ~[]byte | ~string, RelatedID ~[]byte | ~string] interface { // Add the given relationIDs to ID Add(ctx context.Context, tx Tx, id ID, relatedIds []RelatedID) error // Replace all relations of id with the given Replace(ctx context.Context, tx Tx, id ID, relatedIds []RelatedID) error // Remove all relation from ID to the given Remove(ctx context.Context, tx Tx, id ID, relatedIds []RelatedID) error // Delete ID and all relations Delete(ctx context.Context, tx Tx, id ID) error // RelatedIDs return all relation of ID RelatedIDs(ctx context.Context, tx Tx, id ID) ([]RelatedID, error) // IDs return all ids of RelatedID IDs(ctx context.Context, tx Tx, relatedId RelatedID) ([]ID, error) // StreamIDs return all existings IDs StreamIDs(ctx context.Context, tx Tx, ch chan<- ID) error // StreamRelatedIDs return all existings relationIDs StreamRelatedIDs(ctx context.Context, tx Tx, ch chan<- RelatedID) error }
func NewRelationStoreTx ¶
type RelationStoreTxString ¶
type RelationStoreTxString RelationStoreTx[string, string]
type Store ¶
type Store[KEY ~[]byte | ~string, OBJECT any] interface { StoreAdder[KEY, OBJECT] StoreRemover[KEY] StoreGetter[KEY, OBJECT] StoreMapper[KEY, OBJECT] StoreExists[KEY, OBJECT] StoreStream[KEY, OBJECT] }
type StoreAdder ¶
type StoreAdderTx ¶
type StoreExists ¶
type StoreExistsTx ¶
type StoreGetter ¶
type StoreGetterTx ¶
type StoreMapper ¶
type StoreMapperTx ¶
type StoreRemover ¶
type StoreRemoverTx ¶
type StoreStream ¶
type StoreStreamTx ¶
type StoreTx ¶
type StoreTx[KEY ~[]byte | ~string, OBJECT any] interface { StoreAdderTx[KEY, OBJECT] StoreRemoverTx[KEY] StoreGetterTx[KEY, OBJECT] StoreMapperTx[KEY, OBJECT] StoreExistsTx[KEY, OBJECT] StoreStreamTx[KEY, OBJECT] }
func NewStoreTx ¶
func NewStoreTx[KEY ~[]byte | ~string, OBJECT any](bucketName BucketName) StoreTx[KEY, OBJECT]
type Tx ¶
type Tx interface {
Bucket(ctx context.Context, name BucketName) (Bucket, error)
CreateBucket(ctx context.Context, name BucketName) (Bucket, error)
CreateBucketIfNotExists(ctx context.Context, name BucketName) (Bucket, error)
DeleteBucket(ctx context.Context, name BucketName) error
ListBucketNames(ctx context.Context) (BucketNames, error)
}
Source Files
¶
- kv_basic-test-suite.go
- kv_bucket-name.go
- kv_bucket-test-suite.go
- kv_bucket.go
- kv_count.go
- kv_db.go
- kv_foreach.go
- kv_item.go
- kv_iterator-test-suite.go
- kv_iterator.go
- kv_json-handler-tx.go
- kv_key.go
- kv_provider.go
- kv_relation-store-tx.go
- kv_relation-store.go
- kv_relation-store_test-suite.go
- kv_reset-bucket-handler.go
- kv_reset-db-handler.go
- kv_store-tx.go
- kv_store.go
- kv_tx.go
Click to show internal directories.
Click to hide internal directories.