Documentation
¶
Overview ¶
Package storage
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
// Put stores a node. Returns true if the node was newly inserted,
// false if it already exists. If the node already exists, this should be
// a no-op. Put provides automatic deduplication via content-addressing in the dag.
Put(ctx context.Context, node *merkle.Node) (bool, error)
// Get retrieves a node by its hash.
Get(ctx context.Context, hash string) (*merkle.Node, error)
// Has checks if a node exists by its hash.
Has(ctx context.Context, hash string) (bool, error)
// List returns all nodes in the store.
List(ctx context.Context) ([]*merkle.Node, error)
// Roots returns all root nodes (nodes with no parent).
Roots(ctx context.Context) ([]*merkle.Node, error)
// Leaves returns all leaf nodes (nodes with no children).
Leaves(ctx context.Context) ([]*merkle.Node, error)
// Ancestry returns the path from a node back to its root (node first, root last).
Ancestry(ctx context.Context, hash string) ([]*merkle.Node, error)
// Depth returns the depth of a node (0 for roots).
Depth(ctx context.Context, hash string) (int, error)
// Migrate applies any pending schema migrations for the storage backend.
// Implementations must be safe to call concurrently from multiple processes.
// For backends that don't require migrations (e.g. in-memory), this is a no-op.
Migrate(ctx context.Context) error
// Close closes the store and releases any resources.
Close() error
}
Driver defines the interface for persisting and retrieving nodes in a storage backend. The Driver is the primary interface for working with pkg/merkle - it handles storage, retrieval, and traversal of nodes per the storage implementor.
type NotFoundError ¶
type NotFoundError struct {
Hash string
}
NotFoundError is returned when a node doesn't exist in the store.
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
driver
Package entdriver
|
Package entdriver |
|
Package migrate provides a versioned schema migration engine for tapes storage backends.
|
Package migrate provides a versioned schema migration engine for tapes storage backends. |
|
Package postgres provides a PostgreSQL-backed storage driver using ent ORM.
|
Package postgres provides a PostgreSQL-backed storage driver using ent ORM. |
|
Package sqlite provides a SQLite-backed storage driver using ent ORM.
|
Package sqlite provides a SQLite-backed storage driver using ent ORM. |
Click to show internal directories.
Click to hide internal directories.