Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrNotImplemented = errors.New("not implemented") )
var ErrNotHashPointer = errors.New("not hash pointer")
var ErrReadOnly = errors.New("read-only store")
var Null = Pointer(nil)
Null is the hash pointer that can't be resolved.
Functions ¶
This section is empty.
Types ¶
type DeleteArgs ¶
type DeleteArgs struct {
Key Key
}
type DeleteReply ¶
type DeleteReply struct{}
type DiskStore ¶
type DiskStore struct {
// contains filtered or unexported fields
}
func NewDiskStore ¶
type Enumerable ¶
type Paired ¶
type Paired struct {
// contains filtered or unexported fields
}
Paired is a store implementation that is meant to provide the benefits of a fast local store and long term persistence and accessibility of cloud storage. Paired writes to the fast store and queues async writes to the slow store. It reads from the fast store if possible. If not, reads from the slow store and copies content to the fast store for next time. It deletes from the slow store first and then from the fast store.
func NewPaired ¶
NewPaired creates a write-back cache from fast to slow. If the log path is empty, the cache is read-only and puts will fail.
func (*Paired) Delete ¶
Delete deletes an item from the slow store first, then from the fast store second. Note that if done in the other order, a concurrent Get could replenish the fast store from the slow store after the deletion, e.g., (1) delete from fast, (2) get from slow, (3) replenish fast, (4) delete from slow. Steps (1) and (4) belong to this method while (2) and (3) belong to Get.
func (*Paired) EnsureBackgroundPuts ¶
func (p *Paired) EnsureBackgroundPuts()
func (*Paired) Put ¶
Put writes an item to the fast store and enqueues it to be written to the slow store asynchronously. Might block if the async write queue is full. Since this operation is used by the code creating a new revision, triggered by "echo snapshot > ctl", this in turn might block the fileserver entirely for the duration of the snapshot. This hasn't happened to me in practice. Could probably use the underlying filesystem as queue (e.g., hard or symbolic links) but that leads to assuming a disk store implementation and I don't want to.
type Pointer ¶
type Pointer []byte
Pointer is the SHA-256 of some blob stored somewhere. In that sense, it points to that blob.
func NewPointer ¶
NewPointer is the inverse function to the Bytes method. This should be used in unpacking from storage. We don't own the passed slice so we'll make a copy.
func NewPointerFromHex ¶
NewPointerFromHex interprets a hex string as a hash pointer.
func RandomPointer ¶
func RandomPointer() Pointer
RandomPointer returns a hash pointer that does not point to anything known. It is used to assign an initial key to a brand new child node.
func (Pointer) Bytes ¶
Bytes returns the hash pointer as a byte slice rather than a hex string, so it's as small as possible. This should be used in packing to storage. It should be treated as read-only, we own the byte slice.
func (Pointer) Hex ¶
Hex returns the hex representation of the bytes making up the hash pointer (32 bytes, therefore 64 characters).
type RemoteStore ¶
type RemoteStore struct {
// contains filtered or unexported fields
}
RemoteStore implements Store by calling a remote endpoint serving a StoreService using net/rpc.
func NewRemoteStore ¶
func NewRemoteStore(network, address string) (*RemoteStore, error)
func (*RemoteStore) Delete ¶
func (s *RemoteStore) Delete(key Key) error
type StoreService ¶
type StoreService struct {
// contains filtered or unexported fields
}
StoreService wraps a Store implementation for use in a net/rpc client-server application.
func NewStoreService ¶
func NewStoreService(delegate Store) *StoreService
func (*StoreService) Delete ¶
func (s *StoreService) Delete(args DeleteArgs, reply *DeleteReply) error