filestore

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package filestore implements a store that saves all the segments to the file system.

The segments are stored as JSON files named after the link hashes. It's a convenient store to use during the development of an agent. However, because it doesn't use an index, it's very slow, and shouldn't be used for production.

Index

Constants

View Source
const (
	// Name is the name set in the store's information.
	Name = "file"

	// Description is the description set in the store's information.
	Description = "Stratumn's File Store"

	// DefaultPath is the path where segments will be saved by default.
	DefaultPath = "/var/stratumn/filestore"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	*bufferedbatch.Batch
	// contains filtered or unexported fields
}

Batch is the type that implements github.com/stratumn/go-core/store.Batch.

func NewBatch

func NewBatch(ctx context.Context, a *FileStore) *Batch

NewBatch creates a new Batch

func (*Batch) Write

func (b *Batch) Write(ctx context.Context) (err error)

Write implements github.com/stratumn/go-core/store.Batch.Write

type Config

type Config struct {
	// A version string that will be set in the store's information.
	Version string

	// A git commit hash that will be set in the store's information.
	Commit string

	// Path where segments will be saved.
	Path string
}

Config contains configuration options for the store.

type FileStore

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

FileStore is the type that implements github.com/stratumn/go-core/store.Adapter.

func New

func New(config *Config) (*FileStore, error)

New creates an instance of a FileStore.

func (*FileStore) AddEvidence added in v0.2.0

func (a *FileStore) AddEvidence(ctx context.Context, linkHash chainscript.LinkHash, evidence *chainscript.Evidence) error

AddEvidence implements github.com/stratumn/go-core/store.EvidenceWriter.AddEvidence.

func (*FileStore) AddStoreEventChannel added in v0.2.0

func (a *FileStore) AddStoreEventChannel(eventChan chan *store.Event)

AddStoreEventChannel implements github.com/stratumn/go-core/store.Adapter.AddStoreEventChannel

func (a *FileStore) CreateLink(ctx context.Context, link *chainscript.Link) (chainscript.LinkHash, error)

CreateLink implements github.com/stratumn/go-core/store.LinkWriter.CreateLink.

func (*FileStore) DeleteValue

func (a *FileStore) DeleteValue(ctx context.Context, key []byte) ([]byte, error)

DeleteValue implements github.com/stratumn/go-core/store.KeyValueStore.DeleteValue.

func (*FileStore) FindSegments

func (a *FileStore) FindSegments(ctx context.Context, filter *store.SegmentFilter) (*types.PaginatedSegments, error)

FindSegments implements github.com/stratumn/go-core/store.SegmentReader.FindSegments.

func (*FileStore) GetEvidences added in v0.2.0

func (a *FileStore) GetEvidences(ctx context.Context, linkHash chainscript.LinkHash) (types.EvidenceSlice, error)

GetEvidences implements github.com/stratumn/go-core/store.EvidenceReader.GetEvidences.

func (*FileStore) GetInfo

func (a *FileStore) GetInfo(ctx context.Context) (interface{}, error)

GetInfo implements github.com/stratumn/go-core/store.Adapter.GetInfo.

func (*FileStore) GetMapIDs

func (a *FileStore) GetMapIDs(ctx context.Context, filter *store.MapFilter) ([]string, error)

GetMapIDs implements github.com/stratumn/go-core/store.SegmentReader.GetMapIDs.

func (*FileStore) GetSegment

func (a *FileStore) GetSegment(ctx context.Context, linkHash chainscript.LinkHash) (*chainscript.Segment, error)

GetSegment implements github.com/stratumn/go-core/store.SegmentReader.GetSegment.

func (*FileStore) GetValue

func (a *FileStore) GetValue(ctx context.Context, key []byte) ([]byte, error)

GetValue implements github.com/stratumn/go-core/store.KeyValueStore.GetValue.

func (*FileStore) NewBatch

func (a *FileStore) NewBatch(ctx context.Context) (store.Batch, error)

NewBatch implements github.com/stratumn/go-core/store.Adapter.NewBatch.

func (*FileStore) SetValue added in v0.2.0

func (a *FileStore) SetValue(ctx context.Context, key []byte, value []byte) error

SetValue implements github.com/stratumn/go-core/store.KeyValueStore.SetValue.

type Info

type Info struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Version     string `json:"version"`
	Commit      string `json:"commit"`
}

Info is the info returned by GetInfo.

Jump to

Keyboard shortcuts

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