repo

package
v0.4.3-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrApiNotRunning = errors.New("api not running")
)

Functions

This section is empty.

Types

type Datastore

type Datastore interface {
	ds.Batching // should be threadsafe, just be careful
	io.Closer
}

Datastore is the interface required from a datastore to be acceptable to FSRepo.

type Mock

type Mock struct {
	C config.Config
	D Datastore
}

Mock is not thread-safe

func (*Mock) Close

func (m *Mock) Close() error

func (*Mock) Config

func (m *Mock) Config() (*config.Config, error)

func (*Mock) Datastore

func (m *Mock) Datastore() Datastore

func (*Mock) GetConfigKey

func (m *Mock) GetConfigKey(key string) (interface{}, error)

func (*Mock) GetStorageUsage

func (m *Mock) GetStorageUsage() (uint64, error)

func (*Mock) SetAPIAddr

func (m *Mock) SetAPIAddr(addr string) error

func (*Mock) SetConfig

func (m *Mock) SetConfig(updated *config.Config) error

func (*Mock) SetConfigKey

func (m *Mock) SetConfigKey(key string, value interface{}) error

type OnlyOne

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

OnlyOne tracks open Repos by arbitrary key and returns the already open one.

func (*OnlyOne) Open

func (o *OnlyOne) Open(key interface{}, open func() (Repo, error)) (Repo, error)

Open a Repo identified by key. If Repo is not already open, the open function is called, and the result is remember for further use.

Key must be comparable, or Open will panic. Make sure to pick keys that are unique across different concrete Repo implementations, e.g. by creating a local type:

type repoKey string
r, err := o.Open(repoKey(path), open)

Call Repo.Close when done.

type Repo

type Repo interface {
	Config() (*config.Config, error)
	SetConfig(*config.Config) error

	SetConfigKey(key string, value interface{}) error
	GetConfigKey(key string) (interface{}, error)

	Datastore() Datastore
	GetStorageUsage() (uint64, error)

	// SetAPIAddr sets the API address in the repo.
	SetAPIAddr(addr string) error

	io.Closer
}

Directories

Path Synopsis
package config implements the ipfs config file datastructures and utilities.
package config implements the ipfs config file datastructures and utilities.
package fsrepo TODO explain the package roadmap...
package fsrepo TODO explain the package roadmap...

Jump to

Keyboard shortcuts

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