Documentation ¶
Index ¶
- Variables
- func DiskUsage(ctx context.Context, d Datastore) (uint64, error)
- func GetBackedHas(ctx context.Context, ds Read, key Key) (bool, error)
- func GetBackedSize(ctx context.Context, ds Read, key Key) (int, error)
- func NamespaceType(namespace string) string
- func NamespaceValue(namespace string) string
- type Batch
- type Batching
- type CheckedDatastore
- type Datastore
- type GCDatastore
- type Key
- func (k Key) BaseNamespace() string
- func (k Key) Bytes() []byte
- func (k Key) Child(k2 Key) Key
- func (k Key) ChildString(s string) Key
- func (k *Key) Clean()
- func (k Key) Equal(k2 Key) bool
- func (k Key) Instance(s string) Key
- func (k Key) IsAncestorOf(other Key) bool
- func (k Key) IsDescendantOf(other Key) bool
- func (k Key) IsTopLevel() bool
- func (k Key) Less(k2 Key) bool
- func (k Key) List() []string
- func (k Key) MarshalJSON() ([]byte, error)
- func (k Key) Name() string
- func (k Key) Namespaces() []string
- func (k Key) Parent() Key
- func (k Key) Path() Key
- func (k Key) Reverse() Key
- func (k Key) String() string
- func (k Key) Type() string
- func (k *Key) UnmarshalJSON(data []byte) error
- type KeySlice
- type PersistentDatastore
- type Read
- type Repo
- type ScrubbedDatastore
- type TTL
- type TTLDatastore
- type Txn
- type TxnDatastore
- type Write
Constants ¶
This section is empty.
Variables ¶
var (
ErrApiNotRunning = errors.New("api not running")
)
var ErrNotFound error = &dsError{error: errors.New("datastore: key not found"), isNotFound: true}
ErrNotFound is returned by Get and GetSize when a datastore does not map the given key to a value.
Functions ¶
func DiskUsage ¶
DiskUsage checks if a Datastore is a PersistentDatastore and returns its DiskUsage(), otherwise returns 0.
func GetBackedHas ¶
GetBackedHas provides a default Datastore.Has implementation. It exists so Datastore.Has implementations can use it, like so:
func (*d SomeDatastore) Has(key Key) (exists bool, err error) { return GetBackedHas(d, key) }
func GetBackedSize ¶
GetBackedSize provides a default Datastore.GetSize implementation. It exists so Datastore.GetSize implementations can use it, like so:
func (*d SomeDatastore) GetSize(key Key) (size int, err error) { return GetBackedSize(d, key) }
func NamespaceType ¶
NamespaceType is the first component of a namespace. `foo` in `foo:bar`
func NamespaceValue ¶
NamespaceValue returns the last component of a namespace. `baz` in `f:b:baz`
Types ¶
type CheckedDatastore ¶
type GCDatastore ¶
GCDatastore is an interface that should be implemented by datastores which don't free disk space by just removing data from them.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
func KeyWithNamespaces ¶
KeyWithNamespaces constructs a key out of a namespace slice.
func RandomKey ¶
func RandomKey() Key
RandomKey returns a randomly (uuid) generated key.
RandomKey() NewKey("/f98719ea086343f7b71f32ea9d9d521d")
func (Key) BaseNamespace ¶
BaseNamespace returns the "base" namespace of this key (path.Base(filename))
NewKey("/Comedy/MontyPython/Actor:JohnCleese").BaseNamespace() "Actor:JohnCleese"
func (Key) Child ¶
Child returns the `child` Key of this Key.
NewKey("/Comedy/MontyPython").Child(NewKey("Actor:JohnCleese")) NewKey("/Comedy/MontyPython/Actor:JohnCleese")
func (Key) ChildString ¶
ChildString returns the `child` Key of this Key -- string helper.
NewKey("/Comedy/MontyPython").ChildString("Actor:JohnCleese") NewKey("/Comedy/MontyPython/Actor:JohnCleese")
func (Key) Instance ¶
Instance returns an "instance" of this type key (appends value to namespace).
NewKey("/Comedy/MontyPython/Actor").Instance("JohnClesse") NewKey("/Comedy/MontyPython/Actor:JohnCleese")
func (Key) IsAncestorOf ¶
IsAncestorOf returns whether this key is a prefix of `other`
NewKey("/Comedy").IsAncestorOf("/Comedy/MontyPython") true
func (Key) IsDescendantOf ¶
IsDescendantOf returns whether this key contains another as a prefix.
NewKey("/Comedy/MontyPython").IsDescendantOf("/Comedy") true
func (Key) IsTopLevel ¶
IsTopLevel returns whether this key has only one namespace.
func (Key) List ¶
List returns the `list` representation of this Key.
NewKey("/Comedy/MontyPython/Actor:JohnCleese").List() ["Comedy", "MontyPythong", "Actor:JohnCleese"]
func (Key) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface, keys are represented as JSON strings
func (Key) Name ¶
Name returns the "name" of this key (field of last namespace).
NewKey("/Comedy/MontyPython/Actor:JohnCleese").Name() "JohnCleese"
func (Key) Namespaces ¶
Namespaces returns the `namespaces` making up this Key.
NewKey("/Comedy/MontyPython/Actor:JohnCleese").Namespaces() ["Comedy", "MontyPython", "Actor:JohnCleese"]
func (Key) Parent ¶
Parent returns the `parent` Key of this Key.
NewKey("/Comedy/MontyPython/Actor:JohnCleese").Parent() NewKey("/Comedy/MontyPython")
func (Key) Path ¶
Path returns the "path" of this key (parent + type).
NewKey("/Comedy/MontyPython/Actor:JohnCleese").Path() NewKey("/Comedy/MontyPython/Actor")
func (Key) Reverse ¶
Reverse returns the reverse of this Key.
NewKey("/Comedy/MontyPython/Actor:JohnCleese").Reverse() NewKey("/Actor:JohnCleese/MontyPython/Comedy")
func (Key) Type ¶
Type returns the "type" of this key (value of last namespace).
NewKey("/Comedy/MontyPython/Actor:JohnCleese").Type() "Actor"
func (*Key) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface, keys will parse any value specified as a key to a string
type KeySlice ¶
type KeySlice []Key
KeySlice attaches the methods of sort.Interface to []Key, sorting in increasing order.
type PersistentDatastore ¶
type PersistentDatastore interface { Datastore // DiskUsage returns the space used by a datastore, in bytes. DiskUsage(ctx context.Context) (uint64, error) }
PersistentDatastore is an interface that should be implemented by datastores which can report disk usage.
type Repo ¶
type Repo interface { Config() (*config.Config, error) BackupConfig(prefix string) (string, error) SetConfig(*config.Config) error SetConfigKey(key string, value interface{}) GetConfigKey(key string) (interface{}, error) Datastore() Datastore GetStoreSize(context.Context) (uint64, error) Keystore() keystore.Keystore FileManager() *filestore.FileManager ChainManager(networkId string) *quantos.BlockchainManager SetAPIAddr(addr ma.Multiaddr) error SwarmKey() ([]byte, error) io.Closer }
type ScrubbedDatastore ¶
ScrubbedDatastore is an interface that should be implemented by datastores which want to provide a mechanism to check data integrity and/or error correction.
type TTL ¶
type TTL interface { PutWithTTL(ctx context.Context, key Key, value []byte, ttl time.Duration) error SetTTL(ctx context.Context, key Key, ttl time.Duration) error GetExpiration(ctx context.Context, key Key) (time.Time, error) }
TTL encapulates the methods that deal with entries with time-to-live.
type TTLDatastore ¶
TTLDatastore is an interface that should be implemented by datastores that support expiring entries.
type Txn ¶
type Txn interface { Read Write // Commit finalizes a transaction, attempting to commit it to the Datastore. // May return an error if the transaction has gone stale. The presence of an // error is an indication that the data was not committed to the Datastore. Commit(ctx context.Context) error // Discard throws away changes recorded in a transaction without committing // them to the underlying Datastore. Any calls made to Discard after Commit // has been successfully called will have no effect on the transaction and // state of the Datastore, making it safe to defer. Discard(ctx context.Context) }
Txn extends the Datastore type. Txns allow users to batch queries and mutations to the Datastore into atomic groups, or transactions. Actions performed on a transaction will not take hold until a successful call to Commit has been made. Likewise, transactions can be aborted by calling Discard before a successful Commit has been made.