Files
dolt/chunks/chunk_store.go
Chris Masone 507b881c21 Make named DataStores first-class citizens
In order to allow tools like shove to correctly address named
DataStores, we need to have the notion of a name be settable at the
DataStoreFlags level. Once we've done that, it doesn't really make
sense to have API surface for creating DataStores without a name --
though for compatibility, the code will continue to accept an empty
string for a DataStore's name
2016-02-01 10:50:54 -08:00

44 lines
1.4 KiB
Go

package chunks
import (
"io"
"github.com/attic-labs/noms/ref"
)
// ChunkStore is the core storage abstraction in noms. We can put data anyplace we have a ChunkStore implementation for.
type ChunkStore interface {
ChunkSource
ChunkSink
RootTracker
}
// Factory allows the creation of namespaced ChunkStore instances. The details of how namespaces are separated is left up to the particular implementation of Factory and ChunkStore.
type Factory interface {
CreateStore(ns string) ChunkStore
// Shutter shuts down the factory. Subsequent calls to CreateStore() will fail.
Shutter()
}
// RootTracker allows querying and management of the root of an entire tree of references. The "root" is the single mutable variable in a ChunkStore. It can store any ref, but it is typically used by higher layers (such as DataStore) to store a ref to a value that represents the current state and entire history of a datastore.
type RootTracker interface {
Root() ref.Ref
UpdateRoot(current, last ref.Ref) bool
}
// ChunkSource is a place to get chunks from.
type ChunkSource interface {
// Get gets a reader for the value of the Ref in the store. If the ref is absent from the store nil is returned.
Get(ref ref.Ref) Chunk
// Returns true iff the value at the address |ref| is contained in the source
Has(ref ref.Ref) bool
}
// ChunkSink is a place to put chunks.
type ChunkSink interface {
Put(c Chunk)
io.Closer
}