storage

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder added in v0.3.0

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

Builder for ItemStorage

func NewBuilder added in v0.3.0

func NewBuilder() *Builder

func (*Builder) BackedBy added in v0.3.0

func (b *Builder) BackedBy(backing ItemStorageBacking) *Builder

BackedBy can be used if you already have an initialized storage backing.

func (*Builder) Build added in v0.3.0

func (b *Builder) Build() ItemStorage

Build the storage object

func (*Builder) WithBacking added in v0.3.0

func (b *Builder) WithBacking(backingType string) *Builder

WithBacking set the data backing type. ex: boltdb, firebase, sqlite.

func (*Builder) WithDefaultBacking added in v0.3.0

func (b *Builder) WithDefaultBacking() *Builder

WithDefaultBacking sets the storage backing to `boltdb`

func (*Builder) WithEndpoint added in v0.3.0

func (b *Builder) WithEndpoint(endpoint string) *Builder

WithEndpoint if your storage location has a specific location (ex: db path)

func (*Builder) WithNamespace added in v0.3.0

func (b *Builder) WithNamespace(ns string) *Builder

WithNamespace make sure all data is in that namespace

func (*Builder) WithPK added in v0.3.0

func (b *Builder) WithPK(keyFields *indexing.Key) *Builder

WithPK use a primary key to store the data. By default an UUID is used.

func (*Builder) WithRecord added in v0.3.0

func (b *Builder) WithRecord(recordTypePtr interface{}) *Builder

WithRecord set the type of the items you'll be working with, this is needed for unmarshaling and querying.

type ItemStorage

type ItemStorage interface {
	Size() int64
	Find(query indexing.Query, output *search.ExternalResultItem) error
	Add(item search.Record) error
	AddUniqueIndex(key *indexing.Key)
	NewWithKey(pk *indexing.Key) ItemStorage
	Close()
	SetKey(index *indexing.Key) error
	GetNewest(count int) []search.ExternalResultItem
	ForEach(callback func(record interface{}))
}

type ItemStorageBacking

type ItemStorageBacking interface {
	//Tries to find a single record matching the query.
	Find(query indexing.Query, result interface{}) error
	HasIndex(meta *indexing.IndexMetadata) bool
	Update(query indexing.Query, item interface{}) error
	//CreateWithId creates a new record using a custom key
	CreateWithId(parts *indexing.Key, item search.Record, uniqueIndexKeys *indexing.Key) error
	//Create a new record with the default key (UUIDValue)
	Create(item search.Record, additionalPK *indexing.Key) error
	//Size is the size of the storage, as in records count
	Size() int64
	//GetNewest returns the latest `count` of records.
	GetNewest(count int) []search.ExternalResultItem
	Close()
	ForEach(callback func(record interface{}))
}

type KeyedStorage

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

func (*KeyedStorage) Add

func (s *KeyedStorage) Add(item search.Record) error

Add handles the discovery of the result, adding additional information like staleness state.

func (*KeyedStorage) AddUniqueIndex added in v0.2.2

func (s *KeyedStorage) AddUniqueIndex(key *indexing.Key)

AddUniqueIndex adds a new key set as unique for this storage.

func (*KeyedStorage) Close added in v0.2.2

func (s *KeyedStorage) Close()

func (*KeyedStorage) Find added in v0.2.2

func (s *KeyedStorage) Find(query indexing.Query, output *search.ExternalResultItem) error

func (*KeyedStorage) ForEach added in v0.3.0

func (s *KeyedStorage) ForEach(callback func(record interface{}))

func (*KeyedStorage) GetNewest added in v0.2.2

func (s *KeyedStorage) GetNewest(count int) []search.ExternalResultItem

func (*KeyedStorage) NewWithKey

func (s *KeyedStorage) NewWithKey(key *indexing.Key) ItemStorage

NewWithKey gets a storage backed in the same way, with a different key.

func (*KeyedStorage) SetKey added in v0.2.2

func (s *KeyedStorage) SetKey(index *indexing.Key) error

func (*KeyedStorage) Size added in v0.2.2

func (s *KeyedStorage) Size() int64

Directories

Path Synopsis
gob

Jump to

Keyboard shortcuts

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