Documentation
¶
Overview ¶
Package glassdb implements a key-value database on top of cloud object storage with serializable transactions.
Index ¶
- Variables
- type Collection
- func (c Collection) Collection(name []byte) Collection
- func (c Collection) Collections(ctx context.Context) (*CollectionsIter, error)
- func (c Collection) Create(ctx context.Context) error
- func (c Collection) Delete(ctx context.Context, key []byte) error
- func (c Collection) Keys(ctx context.Context) (*KeysIter, error)
- func (c Collection) ReadStrong(ctx context.Context, key []byte) ([]byte, error)
- func (c Collection) ReadWeak(ctx context.Context, key []byte, maxStaleness time.Duration) ([]byte, error)
- func (c Collection) Update(ctx context.Context, key []byte, f func(old []byte) ([]byte, error)) ([]byte, error)
- func (c Collection) Write(ctx context.Context, key, value []byte) error
- type CollectionsIter
- type DB
- type FQKey
- type KeysIter
- type Options
- type ReadResult
- type Stats
- type Tx
Constants ¶
This section is empty.
Variables ¶
var ErrAborted = errors.New("aborted transaction")
ErrAborted is returned when a transaction is explicitly aborted.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection represents a named group of key-value pairs within a database.
func (Collection) Collection ¶
func (c Collection) Collection(name []byte) Collection
Collection returns a sub-collection with the given name.
func (Collection) Collections ¶
func (c Collection) Collections(ctx context.Context) (*CollectionsIter, error)
Collections returns an iterator over the sub-collections in this collection.
func (Collection) Create ¶
func (c Collection) Create(ctx context.Context) error
Create ensures the collection exists in the backend, creating it if necessary.
func (Collection) Delete ¶
func (c Collection) Delete(ctx context.Context, key []byte) error
Delete removes the value associated with key within a transaction.
func (Collection) Keys ¶
func (c Collection) Keys(ctx context.Context) (*KeysIter, error)
Keys returns an iterator over the keys in the collection.
func (Collection) ReadStrong ¶
ReadStrong reads the value for key with strong consistency guarantees.
func (Collection) ReadWeak ¶
func (c Collection) ReadWeak( ctx context.Context, key []byte, maxStaleness time.Duration, ) ([]byte, error)
ReadWeak reads the value for key allowing stale results up to maxStaleness.
type CollectionsIter ¶
type CollectionsIter struct {
// contains filtered or unexported fields
}
CollectionsIter iterates over sub-collections within a collection.
func (*CollectionsIter) Err ¶
func (it *CollectionsIter) Err() error
Err returns the first error encountered during iteration.
func (*CollectionsIter) Next ¶
func (it *CollectionsIter) Next() (name []byte, ok bool)
Next advances the iterator and returns the next collection name.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents an open glassdb database instance.
func (*DB) Collection ¶
func (d *DB) Collection(name []byte) Collection
Collection returns a top-level collection with the given name.
type FQKey ¶
type FQKey struct {
Collection Collection
Key []byte
}
FQKey is a fully qualified key: collection + key name.
type KeysIter ¶
type KeysIter struct {
// contains filtered or unexported fields
}
KeysIter iterates over keys in a collection.
type Options ¶
type Options struct {
Clock clockwork.Clock
Logger *slog.Logger
// Cache size is the number of bytes dedicated to caching objects and
// and metadata. Setting this too small may impact performance, as
// more calls to the backend would be necessary.
CacheSize int
}
Options makes it possible to tweak a client DB.
TODO: Add retry timing options.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions provides the options used by `Open`. They should be a good middle ground for a production deployment.
type ReadResult ¶
ReadResult holds the value or error from a single read in ReadMulti.
type Stats ¶
type Stats struct {
// Transactions statistics.
TxN int // number of completed transactions.
TxTime time.Duration // time spent within transactions.
TxReads int // number of reads.
TxWrites int // number of writes.
TxRetries int // number of retried transactions.
// Backend statistics.
MetaReads int // number of read metadata.
MetaWrites int // number of write metadata.
ObjReads int // number of read objects.
ObjWrites int // number of written objects.
ObjLists int // number of list calls.
}
Stats holds cumulative performance counters for a database.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents an active database transaction.
func (*Tx) Delete ¶
func (t *Tx) Delete(c Collection, key []byte) error
Delete marks the key for deletion within the transaction.
func (*Tx) ReadMulti ¶
func (t *Tx) ReadMulti(ks []FQKey) []ReadResult
ReadMulti reads multiple keys concurrently within the transaction.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package backend defines the interfaces for object storage backends used by glassdb.
|
Package backend defines the interfaces for object storage backends used by glassdb. |
|
gcs
Package gcs implements the backend interface using Google Cloud Storage.
|
Package gcs implements the backend interface using Google Cloud Storage. |
|
memory
Package memory implements an in-memory backend for testing and development.
|
Package memory implements an in-memory backend for testing and development. |
|
middleware
Package middleware provides decorators for backend implementations, including logging and latency simulation.
|
Package middleware provides decorators for backend implementations, including logging and latency simulation. |
|
Demo demonstrates basic glassdb functionality against a GCS backend.
|
Demo demonstrates basic glassdb functionality against a GCS backend. |
|
hack
|
|
|
backendbench
command
Backendbench benchmarks backend storage operation latencies.
|
Backendbench benchmarks backend storage operation latencies. |
|
debug
command
Debug provides commands for analyzing glassdb internals such as decoding paths, parsing logs, and generating call graphs.
|
Debug provides commands for analyzing glassdb internals such as decoding paths, parsing logs, and generating call graphs. |
|
rtbench
command
Rtbench measures database transaction performance under various concurrency scenarios.
|
Rtbench measures database transaction performance under various concurrency scenarios. |
|
internal
|
|
|
cache
Package cache implements a thread-safe LRU cache with size-based eviction.
|
Package cache implements a thread-safe LRU cache with size-based eviction. |
|
concurr
Package concurr provides concurrency utilities including goroutine management, fan-out execution, and retry with backoff.
|
Package concurr provides concurrency utilities including goroutine management, fan-out execution, and retry with backoff. |
|
data
Package data defines common data types for transaction identifiers and related operations.
|
Package data defines common data types for transaction identifiers and related operations. |
|
data/paths
Package paths encodes and decodes storage paths for database objects.
|
Package paths encodes and decodes storage paths for database objects. |
|
errors
Package errors provides utilities for annotating and combining errors.
|
Package errors provides utilities for annotating and combining errors. |
|
proto
Package proto contains protocol buffer definitions and generated code for internal serialization.
|
Package proto contains protocol buffer definitions and generated code for internal serialization. |
|
storage
Package storage manages global and local storage layers with caching and version tracking.
|
Package storage manages global and local storage layers with caching and version tracking. |
|
stringset
Package stringset helps with common set operations on strings.
|
Package stringset helps with common set operations on strings. |
|
testkit
Package testkit provides testing utilities including fake clocks, in-memory GCS clients, and controllable backends.
|
Package testkit provides testing utilities including fake clocks, in-memory GCS clients, and controllable backends. |
|
testkit/bench
Package bench provides utilities for collecting and analyzing performance measurements.
|
Package bench provides utilities for collecting and analyzing performance measurements. |
|
trace
Package trace provides conditional runtime tracing support controlled by build tags.
|
Package trace provides conditional runtime tracing support controlled by build tags. |
|
trans
Package trans implements the transaction processing algorithm with serializable isolation.
|
Package trans implements the transaction processing algorithm with serializable isolation. |




