fsrepo

package
v0.0.0-...-7d4678c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("datastore closed")

Functions

func Init

func Init(repoPath string, conf *config.Config) error

Init initializes a new FSRepo at the given path with the provided config.

func IsInitialized

func IsInitialized(path string) bool

IsInitialized returns true if the repo is initialized at provided |path|.

func Open

func Open(repoPath string) (repo.Repo, error)

Open the FSRepo at path. Returns an error if the repo is not initialized.

Types

type Datastore

type Datastore struct {
	DB *badger.DB
	// contains filtered or unexported fields
}

func Create

func Create(path string) (*Datastore, error)

func NewDatastore

func NewDatastore(path string, options *Options) (*Datastore, error)

NewDatastore creates a new badger datastore.

DO NOT set the Dir and/or ValuePath fields of opt, they will be set for you.

func (*Datastore) Batch

func (d *Datastore) Batch() (ds.Batch, error)

func (*Datastore) Close

func (d *Datastore) Close() error

func (*Datastore) CollectGarbage

func (d *Datastore) CollectGarbage() error

func (*Datastore) Delete

func (d *Datastore) Delete(key ds.Key) error

func (*Datastore) DiskUsage

func (d *Datastore) DiskUsage() (uint64, error)

DiskUsage implements the PersistentDatastore interface. It returns the sum of lsm and value log files sizes in bytes.

func (*Datastore) Get

func (d *Datastore) Get(key ds.Key) (value []byte, err error)

func (*Datastore) GetExpiration

func (d *Datastore) GetExpiration(key ds.Key) (time.Time, error)

func (*Datastore) GetSize

func (d *Datastore) GetSize(key ds.Key) (size int, err error)

func (*Datastore) Has

func (d *Datastore) Has(key ds.Key) (bool, error)

func (*Datastore) NewTransaction

func (d *Datastore) NewTransaction(readOnly bool) (ds.Txn, error)

NewTransaction starts a new transaction. The resulting transaction object can be mutated without incurring changes to the underlying Datastore until the transaction is Committed.

func (*Datastore) Put

func (d *Datastore) Put(key ds.Key, value []byte) error

func (*Datastore) PutWithTTL

func (d *Datastore) PutWithTTL(key ds.Key, value []byte, ttl time.Duration) error

func (*Datastore) Query

func (d *Datastore) Query(q dsq.Query) (dsq.Results, error)

func (*Datastore) SetTTL

func (d *Datastore) SetTTL(key ds.Key, ttl time.Duration) error

type FSRepo

type FSRepo struct {
	// contains filtered or unexported fields
}

FSRepo represents an IPFS FileSystem Repo. It is safe for use by multiple callers.

func (*FSRepo) Close

func (r *FSRepo) Close() error

func (*FSRepo) Config

func (r *FSRepo) Config() (*config.Config, error)

Config the current config. This function DOES NOT copy the config. The caller MUST NOT modify it without first calling `Clone`.

Result when not Open is undefined. The method may panic if it pleases.

func (*FSRepo) Datastore

func (r *FSRepo) Datastore() repo.Datastore

Datastore returns a repo-owned datastore. If FSRepo is Closed, return value is undefined.

func (*FSRepo) GC

func (r *FSRepo) GC() error

func (*FSRepo) Path

func (r *FSRepo) Path() string

type NoRepoError

type NoRepoError struct {
	Path string
}

func (NoRepoError) Error

func (err NoRepoError) Error() string

type Options

type Options struct {
	badger.Options
}

Options are the badger datastore options, reexported here for convenience.

var DefaultOptions Options

DefaultOptions are the default options for the badger datastore.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL