storage

package
v0.0.0-...-f21e4be Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDataNotFound = errors.New("Data not found on the storage")

Functions

This section is empty.

Types

type IPFS

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

IPFS structu contains the IPFS shell connection

The OpenRead method conforms to ipld.BlockReadOpener, and the OpenWrite method conforms to ipld.BlockWriteOpener. Therefore it's easy to use in a LinkSystem like this:

store := storage.Redis{}
lsys.StorageReadOpener = (&store).OpenRead
lsys.StorageWriteOpener = (&store).OpenWrite

func (*IPFS) OpenRead

func (store *IPFS) OpenRead(_ ipld.LinkContext, lnk ipld.Link) (io.Reader, error)

func (*IPFS) OpenWrite

func (store *IPFS) OpenWrite(_ ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error)

type Memory

type Memory struct {
	Bag map[ipld.Link][]byte
}

Memory is a simple in-memory storage for data indexed by ipld.Link. (It's little more than a map -- in fact, the map is exported, and you can poke it directly.)

The OpenRead method conforms to ipld.BlockReadOpener, and the OpenWrite method conforms to ipld.BlockWriteOpener. Therefore it's easy to use in a LinkSystem like this:

store := storage.Memory{}
lsys.StorageReadOpener = (&store).OpenRead
lsys.StorageWriteOpener = (&store).OpenWrite

This storage is mostly expected to be used for testing and demos, and as an example of how you can implement and integrate your own storage systems.

func (*Memory) OpenRead

func (store *Memory) OpenRead(_ ipld.LinkContext, lnk ipld.Link) (io.Reader, error)

func (*Memory) OpenWrite

func (store *Memory) OpenWrite(_ ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error)

type Redis

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

Redis is a key value storage for data indexed by ipld.Link.

The OpenRead method conforms to ipld.BlockReadOpener, and the OpenWrite method conforms to ipld.BlockWriteOpener. Therefore it's easy to use in a LinkSystem like this:

store := storage.Redis{}
lsys.StorageReadOpener = (&store).OpenRead
lsys.StorageWriteOpener = (&store).OpenWrite

func (*Redis) OpenRead

func (store *Redis) OpenRead(lnkContext ipld.LinkContext, lnk ipld.Link) (io.Reader, error)

func (*Redis) OpenWrite

func (store *Redis) OpenWrite(lnkContext ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error)

type Storage

type Storage interface {
	OpenRead(lnkCtx ipld.LinkContext, lnk ipld.Link) (io.Reader, error)
	OpenWrite(lnkCtx ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error)
}

Storage represents the default interface for linkable data

func NewIPFSStorage

func NewIPFSStorage(shell *ipfsApi.Shell) Storage

func NewMemoryStorage

func NewMemoryStorage() Storage

func NewRedisStorage

func NewRedisStorage(addr, passwd string) Storage

Jump to

Keyboard shortcuts

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